{"record":{"id":"a11a8ba8a61af015","repo":"NationalSecurityAgency/ghidra","slug":"given-platform-does-not-belong-to-this-trace","errorCode":null,"errorMessage":"Given platform does not belong to this trace","messagePattern":"Given platform does not belong to this trace","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTracePlatformManager.java","lineNumber":376,"sourceCode":"\t\t\t}\n\t\t\tplatform = doAddGuestPlatform(compilerSpec);\n\t\t}\n\t\ttrace.setChanged(new TraceChangeRecord<>(TraceEvents.PLATFORM_ADDED, null, platform));\n\t\treturn platform;\n\t}\n\n\t@Override\n\tpublic Collection<TraceGuestPlatform> getGuestPlatforms() {\n\t\treturn platformView;\n\t}\n\n\t@Internal\n\tpublic InternalTracePlatform assertMine(TracePlatform platform) {\n\t\tif (platform == hostPlatform) {\n\t\t\treturn hostPlatform;\n\t\t}\n\t\tif (!(platform instanceof DBTraceGuestPlatform)) {\n\t\t\tthrow new IllegalArgumentException(\"Given platform does not belong to this trace\");\n\t\t}\n\t\tDBTraceGuestPlatform dbPlatform = (DBTraceGuestPlatform) platform;\n\t\tif (dbPlatform.manager != this) {\n\t\t\tthrow new IllegalArgumentException(\"Given platform does not belong to this trace\");\n\t\t}\n\t\tif (dbPlatform.isDeleted()) {\n\t\t\tthrow new IllegalArgumentException(\"Given platform has been deleted\");\n\t\t}\n\t\treturn dbPlatform;\n\t}\n\n\tprotected Address computeNextRegisterMin() {\n\t\tAddressRange hostRegsRange = hostPlatform.getRegistersRange();\n\t\tAddress next = hostRegsRange == null\n\t\t\t\t? hostPlatform.getAddressFactory().getRegisterSpace().getAddress(0)\n\t\t\t\t: hostRegsRange.getMaxAddress().add(1);\n\t\tfor (DBTraceGuestPlatform guest : platformStore.asMap().values()) {\n\t\t\tAddress candidateNext = guest.computeNextRegisterMin();","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTracePlatformManager.java#L358-L394","documentation":"assertMine validates that a TracePlatform belongs to this trace's platform manager. This variant fires when platform is neither the host platform nor an instance of DBTraceGuestPlatform (e.g. a mock or a platform from a different trace implementation). IllegalArgumentException(\"Given platform does not belong to this trace\").","triggerScenarios":"Passing a platform obtained from a different DBTrace, a mock platform used in tests, or any non-DBTraceGuestPlatform into an API that internally calls assertMine.","commonSituations":"Multi-trace tooling mixing platform references; stale references after reopening a trace; test code using fake platform objects against real manager APIs.","solutions":["Obtain platforms only from the same trace's getPlatform / getGuestPlatforms.","Verify platform instanceof DBTraceGuestPlatform (or is the host) before passing.","Do not share platform objects across traces; re-fetch per trace."],"exampleFix":"// before\nmgr.someOp(platformFromOtherTrace);\n\n// after\nif (!(platform instanceof DBTraceGuestPlatform) && platform != mgr.getHostPlatform()) {\n    throw new IllegalArgumentException(\"foreign platform\");\n}\nmgr.someOp(platform);","handlingStrategy":"type-guard","validationCode":"if (!(platform instanceof DBTraceGuestPlatform) && platform != mgr.getHostPlatform()) {\n    // foreign/non-DB platform; do not pass to this manager\n}","typeGuard":"static boolean isMinePlatform(DBTracePlatformManager mgr, TracePlatform p) {\n    return p == mgr.getHostPlatform() || p instanceof DBTraceGuestPlatform;\n}","tryCatchPattern":null,"preventionTips":["Source platforms only from the owning trace's manager.","Do not pass mock platforms into production manager APIs.","Type-check at integration boundaries before calling assertMine."],"tags":["platform","ownership","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}