{"record":{"id":"b4bbea04cc41d641","repo":"NationalSecurityAgency/ghidra","slug":"table-is-corrupt-got-host-platform-in-guest-mappi","errorCode":null,"errorMessage":"Table is corrupt. Got host platform in guest mapping.","messagePattern":"Table is corrupt\\. Got host platform in guest mapping\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatformMappedRange.java","lineNumber":94,"sourceCode":"\t\t\tDBRecord r) {\n\t\tsuper(s, r);\n\t\tthis.manager = manager;\n\t}\n\n\t@Override\n\tprotected void fresh(boolean created) throws IOException {\n\t\tsuper.fresh(created);\n\t\tif (created) {\n\t\t\treturn;\n\t\t}\n\t\tthis.hostSpace = manager.trace.getBaseAddressFactory().getAddressSpace(hostSpaceID);\n\t\tAddress hostStart = hostSpace.getAddress(hostOffset);\n\t\tAddress hostEnd = hostStart.addWrap(length - 1);\n\t\tthis.hostRange = new AddressRangeImpl(hostStart, hostEnd);\n\n\t\tInternalTracePlatform platform = manager.getPlatformByKey(guestPlatformKey);\n\t\tif (platform.isHost()) {\n\t\t\tthrow new IOException(\"Table is corrupt. Got host platform in guest mapping.\");\n\t\t}\n\t\tthis.platform = (DBTraceGuestPlatform) platform;\n\t\tthis.guestSpace = platform.getAddressFactory().getAddressSpace(guestSpaceID);\n\t\tAddress guestStart = guestSpace.getAddress(guestOffset);\n\t\tAddress guestEnd = guestStart.addWrap(length - 1);\n\t\tthis.guestRange = new AddressRangeImpl(guestStart, guestEnd);\n\n\t\tthis.shiftHostToGuest = guestStart.getOffset() - hostStart.getOffset();\n\t}\n\n\tvoid set(Address hostStart, DBTraceGuestPlatform platform, Address guestStart, long length) {\n\t\tthis.hostSpace = hostStart.getAddressSpace();\n\t\tthis.hostSpaceID = hostSpace.getSpaceID();\n\t\tthis.hostOffset = hostStart.getOffset();\n\t\tthis.guestPlatformKey = (int) platform.getKey();\n\t\tthis.guestSpace = guestStart.getAddressSpace();\n\t\tthis.guestSpaceID = guestSpace.getSpaceID();\n\t\tthis.guestOffset = guestStart.getOffset();","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatformMappedRange.java#L76-L112","documentation":"When loading a stored DBTraceGuestPlatformMappedRange, fresh() resolves the guest platform by key via manager.getPlatformByKey(guestPlatformKey); if platform.isHost() it throws IOException(\"Table is corrupt. Got host platform in guest mapping.\"). A mapped-range row references the host platform where only a guest platform is valid, so the row is internally inconsistent.","triggerScenarios":"Corrupt DB where a mapped-range row's guestPlatformKey points at the host platform key; tampered or partially-written table from a crash during write; schema bug writing the wrong key.","commonSituations":"Hand-edited DB; crash leaving half-written rows; bug in platform key assignment producing the host key in a guest-mapping row.","solutions":["Restore the trace from a known-good backup.","Rebuild the guest platform and its mappings from scratch.","Report as corruption; there is no runtime workaround that can rehydrate an inconsistent row."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// no runtime preflight: detect by validating DB integrity off-line\n// (a mapped-range row must not reference the host platform key)","typeGuard":null,"tryCatchPattern":"try { trace.open(...); }\ncatch (IOException e) {\n    if (e.getMessage().contains(\"Got host platform in guest mapping\")) { /* corrupt DB; restore backup */ }\n    else throw e;\n}","preventionTips":["Back up trace DBs before risky migrations.","Avoid editing the trace DB by hand.","Treat this as unrecoverable corruption and rebuild the platform mappings."],"tags":["corruption","database","mapping","guest-platform"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}