{"record":{"id":"55a1751043163e59","repo":"NationalSecurityAgency/ghidra","slug":"given-namespace-is-not-in-this-trace","errorCode":null,"errorMessage":"Given namespace is not in this trace","messagePattern":"Given namespace is not in this trace","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/symbol/DBTraceSymbolManager.java","lineNumber":475,"sourceCode":"\t\t\treturn null;\n\t\t}\n\t\tlong symbolID = dbSym.getID();\n\t\tbyte tid = unpackTypeID(symbolID);\n\t\tAbstractDBTraceSymbolSingleTypeView<?> view = symbolViews.get(tid);\n\t\tif (view == null) {\n\t\t\treturn null;\n\t\t}\n\t\tif (!view.store.containsKey(unpackKey(symbolID))) {\n\t\t\treturn null;\n\t\t}\n\t\treturn dbSym;\n\t}\n\n\t@Internal\n\tpublic DBTraceNamespaceSymbol assertIsMine(Namespace ns) {\n\t\tDBTraceNamespaceSymbol dbns = checkIsMine(ns);\n\t\tif (dbns == null) {\n\t\t\tthrow new IllegalArgumentException(\"Given namespace is not in this trace\");\n\t\t}\n\t\treturn dbns;\n\t}\n\n\t@Internal\n\tpublic AbstractDBTraceSymbol assertIsMine(Symbol symbol) {\n\t\tAbstractDBTraceSymbol dbSym = checkIsMine(symbol);\n\t\tif (dbSym == null) {\n\t\t\tthrow new IllegalArgumentException(\"Given symbol is not in this trace\");\n\t\t}\n\t\treturn dbSym;\n\t}\n\n\tprotected static void assertValidName(String name) throws InvalidInputException {\n\t\tif (name == null || name.length() == 0 || !name.matches(\"\\\\p{Graph}+\")) {\n\t\t\tthrow new InvalidInputException(name);\n\t\t}\n\t}","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/symbol/DBTraceSymbolManager.java#L457-L493","documentation":"Thrown by DBTraceSymbolManager.assertIsMine(Namespace): the helper checkIsMine(ns) returned null, meaning the namespace is either not a DBTraceNamespaceSymbol or does not belong to this trace. The guard prevents operations on namespaces sourced from a different trace or from the Program namespace API.","triggerScenarios":"Passing a Namespace obtained from another Trace, from a Program (e.g. listing.getFunction(name).getParentNamespace()), or a mock/stub namespace into a trace symbol operation that calls assertIsMine(Namespace).","commonSituations":"Cross-trace copying of symbols; reusing a cached Namespace after the trace was closed; test code with mocked namespaces; mixing Program global namespace into trace symbol creation.","solutions":["Resolve or create the namespace within the target trace via trace.getSymbolManager().getOrCreateNamespace(...) before using it.","Map foreign namespace names to namespaces owned by this trace.","Guard with instanceof DBTraceNamespaceSymbol and trace ownership before calling assertIsMine-dependent APIs.","Avoid caching Namespace handles across trace lifetimes."],"exampleFix":"// before\nsymMgr.createLabel(span, addr, name, foreignNs, SourceType.USER, null);\n\n// after\nNamespace myNs = symMgr.getOrCreateNamespace(trace.getSymbolManager().getGlobalNamespace(), foreignNs.getName());\nsymMgr.createLabel(span, addr, name, myNs, SourceType.USER, null);","handlingStrategy":"validation","validationCode":"Namespace myNs = (ns instanceof DBTraceNamespaceSymbol dbns\n        && dbns.getTrace() == thisTrace)\n    ? ns\n    : symMgr.getOrCreateNamespace(symMgr.getGlobalNamespace(), ns != null ? ns.getName() : \"\");","typeGuard":"static boolean isMineNs(Trace trace, Namespace ns) {\n    return ns instanceof DBTraceNamespaceSymbol dbns && dbns.getTrace() == trace;\n}","tryCatchPattern":null,"preventionTips":["Resolve namespaces inside the target trace rather than reusing foreign Program/Trace namespaces.","Do not cache Namespace handles past the trace's lifetime."],"tags":["ghidra","trace-modeling","symbol","namespace","ownership","illegal-argument"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}