{"record":{"id":"4e81a26e9cc48db4","repo":"NationalSecurityAgency/ghidra","slug":"cannot-create-or-remove-default-symbols","errorCode":null,"errorMessage":"Cannot create or remove DEFAULT symbols","messagePattern":"Cannot create or remove DEFAULT symbols","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/symbol/AbstractDBTraceSymbol.java","lineNumber":408,"sourceCode":"\n\t@Override\n\tpublic boolean isValidParent(Namespace ns) {\n\t\tDBTraceNamespaceSymbol dbns = manager.checkIsMine(ns);\n\t\tif (dbns == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn MySymbolTypes.VALUES.get(this.getSymbolType().getID()).isValidParent(dbns);\n\t}\n\n\tprotected DBTraceNamespaceSymbol checkCircular(DBTraceNamespaceSymbol newParent)\n\t\t\tthrows CircularDependencyException {\n\t\treturn newParent;\n\t}\n\n\tprotected Pair<String, SourceType> validateNameAndSource(String newName, SourceType newSource)\n\t\t\tthrows InvalidInputException {\n\t\tif ((newSource == SourceType.DEFAULT) ^ (getSource() == SourceType.DEFAULT)) {\n\t\t\tthrow new IllegalArgumentException(\"Cannot create or remove DEFAULT symbols\");\n\t\t}\n\t\tDBTraceSymbolManager.assertValidName(newName);\n\t\treturn new ImmutablePair<>(newName, newSource);\n\t}\n\n\t@Override\n\tpublic void setName(String newName, SourceType newSource)\n\t\t\tthrows DuplicateNameException, InvalidInputException {\n\t\tassertNotGlobal();\n\t\tPair<String, SourceType> validated = validateNameAndSource(newName, newSource);\n\t\tnewName = validated.getLeft();\n\t\tnewSource = validated.getRight();\n\t\ttry (LockHold hold = LockHold.lock(manager.lock.writeLock())) {\n\t\t\tTraceChangeRecord<?, ?> nameEvent = doSetNameWithEvent(newName);\n\t\t\tTraceChangeRecord<?, ?> sourceEvent = doSetSourceWithEvent(newSource);\n\t\t\tif (nameEvent != null || sourceEvent != null) {\n\t\t\t\tupdate(NAME_COLUMN, FLAGS_COLUMN);\n\t\t\t}","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/symbol/AbstractDBTraceSymbol.java#L390-L426","documentation":"Thrown as IllegalArgumentException by validateNameAndSource when the source type transitions to or from SourceType.DEFAULT (exclusive-or of the two states). DEFAULT is a reserved source state that symbols are created with implicitly and cannot be explicitly assigned or removed via setName. You may only move between non-DEFAULT sources (ANALYSIS, IMPORTED, USER_DEFINED), or have the framework manage DEFAULT transitions internally.","triggerScenarios":"Calling setName(name, SourceType.DEFAULT) on a non-default symbol, or calling setName(name, USER_DEFINED) on a DEFAULT symbol expecting it to stay DEFAULT. The xor fires when exactly one side is DEFAULT.","commonSituations":"Scripts that blindly set USER_DEFINED on auto-generated DEFAULT symbols and then try to revert to DEFAULT; tooling unaware of the DEFAULT convention.","solutions":["Use a non-DEFAULT SourceType (USER_DEFINED / IMPORTED / ANALYSIS) when renaming.","If a symbol is DEFAULT and must stay DEFAULT, do not call setName at all.","To remove a symbol, call remove() rather than downgrading source."],"exampleFix":"// before\nsym.setName(\"new\", SourceType.DEFAULT);\n// after\nsym.setName(\"new\", SourceType.USER_DEFINED);","handlingStrategy":"validation","validationCode":"if ((source == SourceType.DEFAULT) ^ (sym.getSource() == SourceType.DEFAULT)) {\n    // illegal transition; pick a non-DEFAULT source\n    source = SourceType.USER_DEFINED;\n}\nsym.setName(name, source);","typeGuard":"static boolean isLegalSourceTransition(SymbolType cur, SourceType next) {\n    return !((next == SourceType.DEFAULT) ^ (cur == SourceType.DEFAULT));\n}","tryCatchPattern":null,"preventionTips":["Never assign SourceType.DEFAULT explicitly.","Use non-DEFAULT sources when renaming."],"tags":["symbol","source-type","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}