{"record":{"id":"483c70d107b03f8c","repo":"NationalSecurityAgency/ghidra","slug":"symbol-address-s-of-s-must-match-reference-s","errorCode":null,"errorMessage":"Symbol address (%s) of '%s' must match Reference's to address (%s)","messagePattern":"Symbol address \\((.+?)\\) of '(.+?)' must match Reference's to address \\((.+?)\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/symbol/DBTraceReference.java","lineNumber":150,"sourceCode":"\tpublic void setReferenceType(RefType refType) {\n\t\tif (refType == RefType.EXTERNAL_REF) {\n\t\t\tthrow new IllegalArgumentException(\"Trace does not allow external references\");\n\t\t}\n\t\ttry (LockHold hold = LockHold.lock(ent.space.lock.writeLock())) {\n\t\t\tent.setRefType(refType);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setAssociatedSymbol(Symbol symbol) {\n\t\ttry (LockHold hold = LockHold.lock(ent.space.lock.writeLock())) {\n\t\t\tAbstractDBTraceSymbol dbSym = getTrace().getSymbolManager().assertIsMine(symbol);\n\t\t\tif (ent.symbolId == symbol.getID()) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tAddress toAddress = getToAddress();\n\t\t\tif (!Objects.equals(symbol.getAddress(), toAddress)) {\n\t\t\t\tthrow new IllegalArgumentException(String.format(\n\t\t\t\t\t\"Symbol address (%s) of '%s' must match Reference's to address (%s)\",\n\t\t\t\t\tsymbol.getAddress(), symbol.getName(), toAddress));\n\t\t\t}\n\t\t\tif (symbol instanceof TraceSymbolWithLifespan) {\n\t\t\t\tTraceSymbolWithLifespan symWl = (TraceSymbolWithLifespan) symbol;\n\t\t\t\tif (!symWl.getLifespan().intersects(getLifespan())) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"Associated symbol and reference must have connected lifespans\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tent.setSymbolId(symbol.getID());\n\t\t\tgetTrace().setChanged(new TraceChangeRecord<>(TraceEvents.SYMBOL_ASSOCIATION_ADDED,\n\t\t\t\tent.space.space, dbSym, null, this));\n\t\t}\n\t}\n\n\t@Override\n\tpublic void clearAssociatedSymbol() {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/symbol/DBTraceReference.java#L132-L168","documentation":"Thrown as IllegalArgumentException by DBTraceReference.setAssociatedSymbol when the candidate symbol's address does not equal the reference's to-address. A reference's associated (target) symbol must live exactly at the address the reference points to, so that symbol.getAddress() == ref.getToAddress(). This keeps the reference->symbol link consistent.","triggerScenarios":"Passing a Symbol whose address differs from the reference to-address, e.g. associating a function symbol at 0x1000 with a reference whose to-address is 0x2000.","commonSituations":"Lookup-by-name returning a wrong symbol at a different address; stale symbol references after a symbol moved.","solutions":["Look up the symbol at the reference's to-address: symMgr.getSymbolAt(ref.getToAddress()).","Before associating, assert Objects.equals(symbol.getAddress(), ref.getToAddress()).","Re-resolve the symbol if it may have moved."],"exampleFix":"// before\nref.setAssociatedSymbol(symByName);\n// after\nSymbol sym = symMgr.getSymbolAt(ref.getToAddress());\nif (sym != null) ref.setAssociatedSymbol(sym);","handlingStrategy":"validation","validationCode":"if (Objects.equals(symbol.getAddress(), ref.getToAddress())) {\n    ref.setAssociatedSymbol(symbol);\n}","typeGuard":"static boolean symbolMatchesRef(Symbol s, Reference r) {\n    return Objects.equals(s.getAddress(), r.getToAddress());\n}","tryCatchPattern":null,"preventionTips":["Resolve the symbol at the reference to-address, not by name.","Re-resolve symbols that may have moved."],"tags":["reference","symbol","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}