{"record":{"id":"961f889e225918c0","repo":"NationalSecurityAgency/ghidra","slug":"platform-is-not-part-of-this-trace","errorCode":null,"errorMessage":"Platform is not part of this trace","messagePattern":"Platform is not part of this trace","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/DBTraceDefinedDataView.java","lineNumber":76,"sourceCode":"\t * @return true if it is a function definition, false otherwise\n\t */\n\tprotected boolean isFunctionDefinition(DataType dt) {\n\t\tif (dt instanceof FunctionDefinition) {\n\t\t\treturn true;\n\t\t}\n\t\tif (dt instanceof TypeDef) {\n\t\t\tTypeDef typeDef = (TypeDef) dt;\n\t\t\treturn isFunctionDefinition(typeDef.getBaseDataType());\n\t\t}\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic DBTraceDataAdapter create(Lifespan lifespan, Address address, TracePlatform platform,\n\t\t\tDataType origType, int origLength) throws CodeUnitInsertionException {\n\t\tif (platform.getTrace() != getTrace() ||\n\t\t\t!(platform instanceof InternalTracePlatform iPlatform)) {\n\t\t\tthrow new IllegalArgumentException(\"Platform is not part of this trace\");\n\t\t}\n\t\ttry (LockHold hold = LockHold.lock(space.lock.writeLock())) {\n\t\t\tDBTraceMemorySpace memSpace = space.trace.getMemoryManager().get(space.space, true);\n\t\t\t// NOTE: User-given length could be ignored....\n\t\t\t// Check start address first. After I know length, I can check for other existing units\n\t\t\tlong startSnap = lifespan.lmin();\n\t\t\tif (!space.undefinedData.coversRange(Lifespan.at(startSnap),\n\t\t\t\tnew AddressRangeImpl(address, address))) {\n\t\t\t\t// TODO: Figure out the conflicting unit?\n\t\t\t\tthrow new CodeUnitInsertionException(\"Code units cannot overlap\");\n\t\t\t}\n\n\t\t\tDataType dataType;\n\t\t\tint length;\n\t\t\tif (origType instanceof FactoryDataType) {\n\t\t\t\tMemBuffer buffer = memSpace.getBufferAt(startSnap, address);\n\t\t\t\tFactoryDataType fdt = (FactoryDataType) origType;\n\t\t\t\tdataType = fdt.getDataType(buffer);","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/DBTraceDefinedDataView.java#L58-L94","documentation":"Thrown by DBTraceDefinedDataView.create() when the provided TracePlatform does not belong to this trace (platform.getTrace() != getTrace()) or is not an InternalTracePlatform instance. Data units must be created using a platform that is registered with the same trace object, because the data unit records store a platform key that is trace-local. Passing a foreign platform or an incompatible platform implementation is a precondition violation.","triggerScenarios":"Calling view.create(lifespan, address, platform, dataType) with a platform obtained from a different trace, or a custom TracePlatform implementation that is not an InternalTracePlatform. The instanceof + getTrace() check ensures only trace-native platforms are used.","commonSituations":"Using a platform from a different trace session; mixing base host platform and guest platform across traces; mock/test platform implementations that do not extend InternalTracePlatform; refactoring that broke platform-to-trace ownership.","solutions":["Use the platform from the same trace: trace.getPlatformManager().getHostPlatform() or the correct guest platform from the same trace.","Ensure any custom platform extends/implements InternalTracePlatform and is registered with the trace.","Verify platform.getTrace() == trace before calling create()."],"exampleFix":"// before — platform from a different trace\nDBTraceDefinedDataView view = otherTrace.getCodeManager().get(space, true).definedData();\nview.create(lifespan, address, foreignPlatform, dataType); // throws\n\n// after — use the platform from the owning trace\nDBTraceDefinedDataView view = trace.getCodeManager().get(space, true).definedData();\nTracePlatform platform = trace.getPlatformManager().getHostPlatform();\nview.create(lifespan, address, platform, dataType);","handlingStrategy":"validation","validationCode":"// Verify platform ownership before creating data units\nif (platform.getTrace() != trace) {\n    throw new IllegalArgumentException(\"Platform does not belong to this trace\");\n}\nif (!(platform instanceof InternalTracePlatform)) {\n    throw new IllegalArgumentException(\"Platform must be an InternalTracePlatform\");\n}\nview.create(lifespan, address, platform, dataType);","typeGuard":"static boolean isTraceNativePlatform(TracePlatform platform, DBTrace trace) {\n    return platform.getTrace() == trace && platform instanceof InternalTracePlatform;\n}","tryCatchPattern":"try {\n    view.create(lifespan, address, platform, dataType);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"not part of this trace\")) {\n        // Use the correct platform from the owning trace\n        TracePlatform correctPlatform = trace.getPlatformManager().getHostPlatform();\n        view.create(lifespan, address, correctPlatform, dataType);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always obtain the platform from the same trace object: trace.getPlatformManager().getHostPlatform().","Never share platform objects across different trace instances.","Ensure custom platform implementations extend InternalTracePlatform and register with the trace."],"tags":["platform","precondition","create","trace-modeling"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}