Repository navigation
fix(ghidra): mark empty xrefs results as unresolved, not unreferenced - #8831
Conversation
Ghidra 12.2 resolves no references to data addresses on some Mach-O imports, and xrefs returned a bare empty list with nothing separating 'no references exist' from 'this provider resolved no references', so callers concluded addresses were unreferenced. projectExecution now attaches ghidraEmptyXrefsLimitation to an empty xrefs result: the list reflects what this analysis resolved, not proof the address is unreferenced. Non-empty results carry no caveat. Covered by behavior tests for both branches; validated against FM9-Edit-arm64 (expect: limitation) once the daemon session reopens.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge, with no outstanding actionable findings. SummaryThe PR adds warnings so empty Ghidra reference lists do not imply that references are absent. It also updates profile versions to prevent replay of older results without these warnings.
Reviews (12) · Last reviewed commit: "fix(ghidra): qualify dossier incoming ca..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00b2636e8b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...executionMetadata, | ||
| limitations: [ | ||
| ...(executionMetadata.limitations ?? []), | ||
| ghidraEmptyXrefsLimitation, |
There was a problem hiding this comment.
Invalidate cached xrefs observations before adding the caveat
When a caller imports a pre-change analysis snapshot for the same target and Ghidra version, this branch is bypassed because BinarySession returns AnalysisSnapshotCache.lookup before dispatch (src/application/binary/BinarySession.ts:1424-1429), and replay preserves the entry's old limitations (src/application/binary/AnalysisSnapshotCache.ts:506-515). This commit does not revise sharedAnalysisSemantics, so the old profile still matches and a cached empty xrefs result remains bare—the exact false conclusion this change is meant to prevent. Bump the Ghidra analysis-profile semantic revision, which will also invalidate derived workflow snapshots, or explicitly upgrade this cached observation.
AGENTS.md reference: AGENTS.md:L54-L56
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 55d0a52: instruction_references in sharedAnalysisSemantics bumps to exact-address-incoming-without-synthetic-entry-v3. The snapshot binding embeds the full analysis_profile commitment (snapshotBinding), so a snapshot captured before the caveat no longer matches the committed profile (snapshotMatchesProfile → EvidenceIntegrityError, no dispatch) and its bare empty xrefs result is not replayed as current. Admission cases for v2→v3 and v1→v3 added to GhidraSnapshotCache.test.ts; derived workflow snapshots inherit the same invalidation through the profile commitment.
|
|
||
| /** Attached to an empty xrefs result: absence of resolved references is not proof. */ | ||
| export const ghidraEmptyXrefsLimitation = | ||
| "Ghidra's ReferenceManager resolved no references to this address in this session. An empty list reflects what this analysis resolved, not proof that the address is unreferenced; before concluding the address has no xrefs, cross-check the disassembly or use trace_feature on a known string."; |
There was a problem hiding this comment.
Describe filtered references instead of claiming none existed
When an address has only Ghidra's synthetic entry-point references, visitObservedReferencesTo does receive entries from ReferenceManager and then drops them in visitObservedReference (bridge/ghidra/ReaGhidraBridge.java:3963-3974), leaving this result empty. This message therefore falsely says the manager resolved no references and conflicts with the existing xrefs limitation that synthetic entry-point references are omitted; report that no actionable references were returned, or carry observed-versus-filtered counts from the bridge.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 55d0a52: the caveat now says the ReferenceManager returned no actionable references and names the omission (synthetic entry-point references are omitted), consistent with the existing xrefs limitation wording. Carrying observed-versus-filtered counts from the bridge is not included in this change; the caveat directs to the disassembly for confirmation either way.
|
|
||
| /** Attached to an empty xrefs result: absence of resolved references is not proof. */ | ||
| export const ghidraEmptyXrefsLimitation = | ||
| "Ghidra's ReferenceManager resolved no references to this address in this session. An empty list reflects what this analysis resolved, not proof that the address is unreferenced; before concluding the address has no xrefs, cross-check the disassembly or use trace_feature on a known string."; |
There was a problem hiding this comment.
Recommend an independent xrefs recovery path
When this warning is shown for an empty xrefs, trace_feature is not an independent cross-check: traceReferences invokes observe on xrefs for each matched string (src/application/EnhancedLiteralTracing.ts:140-157). On the reported ReferenceManager failure, following this recovery just repeats the same failing observation and can again return no references, so recommend an independent disassembly/reference probe or label this only as a provider-wide diagnostic.
AGENTS.md reference: AGENTS.md:L93-L97
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ff0ddbe: the trace_feature recommendation is removed. The disassembly at the address is the single independent cross-check named by the caveat.
| operation === "xrefs" && | ||
| Array.isArray(normalized) && | ||
| normalized.length === 0 |
There was a problem hiding this comment.
Propagate ReferenceManager uncertainty to sibling tools
When the reported session-wide ReferenceManager failure also affects function queries, this xrefs-only predicate leaves procedure_references and the reference facets of analyze_function unchanged even though both are built by the same collectReferences/visitObservedReferencesTo path (bridge/ghidra/ReaGhidraBridge.java:1160-1183 and :1619-1648). Those public tools can therefore still present empty incoming/outgoing arrays as collected facts without the new uncertainty; originate the ReferenceManager coverage/limitation at its owning boundary and propagate it to all affected consumers.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Acknowledged. procedure_references and analyze_function reference facets are built on the same ReferenceManager observation path, so the same empty-means-unresolved epistemics apply there. This PR keeps the caveat scoped to the xrefs operation where the failure was observed, to keep one focused outcome; extending it to the sibling reference facets would change their Evidence output for legitimately empty results as well, so I am recording it as a proposed follow-up rather than silently expanding this PR's scope. If a maintainer wants it in this PR, the same provider-level attach can generalize to empty reference arrays with its own semantics bump.
There was a problem hiding this comment.
Expanded in 31fd8fd (owner-directed): the caveat now also covers the sibling facets built on the same ReferenceManager observation path. procedure_references attaches ghidraEmptyFunctionReferencesLimitation when the requested direction returns no references; analyze_function attaches it when both incoming_references and outgoing_references are empty (a function-manager-derived caller/callee list alone does not trigger it — those come from a different path and were observed working on the reported target). function_references semantics bump to complete-body-and-entry-reference-manager-v3 invalidates snapshots captured before the caveat; raw profile digests recomputed. Behavior tests cover empty/non-empty for both operations.
… caveat trace_feature calls xrefs internally, so recommending it as an independent cross-check repeats the same lookup the caveat qualifies. Keep disassembly as the single independent check.
… snapshots Review follow-up on the empty xrefs caveat: - The bridge filters synthetic entry-point references before observation, so "resolved no references" could be false; the caveat now reports that no actionable references were returned and names the omission. - Drop the trace_feature cross-check: traceReferences observes xrefs per matched string, repeating the same lookup instead of independent evidence. - Bump instruction_references semantics to v3 so analysis snapshots captured before the caveat replay no bare empty results; the profile commitment in the snapshot binding no longer matches.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55d0a52dec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| /** Attached to an empty xrefs result: absence of resolved references is not proof. */ | ||
| export const ghidraEmptyXrefsLimitation = | ||
| "Ghidra's ReferenceManager returned no actionable references to this address in this session. An empty list reflects what this analysis resolved, not proof that the address is unreferenced; synthetic entry-point references are omitted, so cross-check the disassembly at this address before concluding there are no xrefs."; |
There was a problem hiding this comment.
Point the caveat to an independent disassembly scan
When the empty result is for a string/data address (the motivating failure), cross-check the disassembly at this address is not a usable independent check: the destination has no instruction to disassemble, and Ghidra's inspectNativeInstruction obtains incoming_references through the same visitObservedReferencesTo path (bridge/ghidra/ReaGhidraBridge.java:1303-1408). Fresh evidence after the earlier trace_feature feedback is that the replacement recovery still cannot inspect source instructions elsewhere; direct users to a source-side disassembly/reference scan or state that no independent in-product check is available.
AGENTS.md reference: AGENTS.md:L93-L97
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c2e7de9: both caveats now state the honest limits. The xrefs caveat names that no independent in-product cross-check exists for the empty result — surrounding disassembly only confirms direct references at a code address, while the motivating case (a string address) needs an external disassembly scan (otool -tV, adrp/add pairing). The function-facet caveat separates outgoing references (the function's own disassembly is independent) from incoming references (no in-product check; scan other code externally).
Extends the empty-xrefs caveat to the sibling ReferenceManager consumers review follow-up identified: procedure_references and analyze_function reference facets built on the same observation path could still present empty arrays as collected facts. - ghidraEmptyFunctionReferencesLimitation attaches when procedure_references returns no references for the requested direction and when a dossier observes no references in either direction; callers/callees (function-manager derived, observed working on the reported target) stay caveat-free. - One emptyReferenceCaveat owner replaces the inline xrefs branch. - function_references semantics bump to v3 so snapshots captured before the caveat do not replay bare empty facets; raw profile digests recomputed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31fd8fd3fe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| isEmptyArray(record.outgoing_references) | ||
| ? ghidraEmptyFunctionReferencesLimitation | ||
| : undefined; | ||
| return undefined; |
There was a problem hiding this comment.
Apply the caveat to remaining ReferenceManager consumers
When the session has the reported ReferenceManager failure, this fallthrough still leaves inspect_native_instruction.incoming_references and annotate_native_function.dossier without the new uncertainty limitation. The bridge builds the former with visitObservedReferencesTo (bridge/ghidra/ReaGhidraBridge.java:1401-1408) and the latter by calling the same analyzeFunction collection (bridge/ghidra/ReaGhidraBridge.java:1525-1529), so both can return empty arrays for the same failure while presenting them as ordinary collected facts; handle these result shapes here or attach the coverage at the bridge boundary.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
… caveat Review follow-up: annotate_native_function returns a dossier built by the same analyzeFunction collection and inspect_native_instruction builds incoming_references with visitObservedReferencesTo; both could present empty arrays as collected facts under the reported ReferenceManager failure. - annotate_native_function attaches the caveat when its dossier observes no references in either direction. - inspect_native_instruction attaches it when incoming_references is an explicit empty array (null or omission stays unavailable, matching the field contract). - Split the diagnostics describe to keep each block under the lint bound. - Behavior tests cover attach and non-attach for both operations.
Review follow-up: the motivating failure was a string address, so 'cross-check the disassembly at this address' pointed at nothing — data and string addresses have no instruction to disassemble — and inspect_native_instruction's incoming_references is built through the same visitObservedReferencesTo path, so it was not independent either. - xrefs caveat now states that no independent in-product cross-check exists for the empty result, that surrounding disassembly only helps at a code address, and that data or string addresses need an external disassembly scan (otool -tV adrp/add pairing). - Function-facet caveat separates outgoing references (own disassembly is independent) from incoming references (no in-product check; scan other code externally).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2e7de9950
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return isEmptyArray(record.incoming_references) && | ||
| isEmptyArray(record.outgoing_references) |
There was a problem hiding this comment.
Qualify each empty reference direction independently
When an analyzed function has at least one incoming edge but its outgoing ARM64 data references are the ones Ghidra failed to resolve (or vice versa), this && suppresses the caveat entirely, so the empty direction is still presented as a collected fact even though success in the other direction provides no coverage for it. Fresh evidence after the earlier sibling-consumer thread is the new GhidraProvider.behavior.test.ts:3267-3280, which explicitly locks an empty-incoming/nonempty-outgoing dossier to no caveat; the annotation branch repeats the same all-empty predicate. Emit a direction-aware limitation for each empty facet.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 35396b9. The both-directions-empty predicate is gone: analyze_function and the annotate_native_function dossier readback now attach a direction-scoped limitation for each empty facet (ghidraEmptyIncomingReferencesLimitation / ghidraEmptyOutgoingReferencesLimitation), and procedure_references selects by its requested direction. Each limitation states what the empty observation does and does not establish for that direction — incoming: synthetic entry-point references are omitted and there is no independent in-product check (external otool -tV adrp/add pairing); outgoing: the function's own disassembly is the independent check. The behavior tests that locked the one-direction-no-caveat behavior now assert the per-direction caveat (incoming-only-empty, outgoing-only-empty, both-empty on both operations).
| if (operation === "inspect_native_instruction") | ||
| return isEmptyArray(record.incoming_references) | ||
| ? ghidraEmptyFunctionReferencesLimitation |
There was a problem hiding this comment.
Scope the instruction caveat to the queried address
When inspect_native_instruction is used on a data/not-in-listing address or any address outside a function, the bridge still returns incoming_references: [] with procedure: null (ReaGhidraBridge.java:1303-1408), but this branch attaches ghidraEmptyFunctionReferencesLimitation, whose message claims no references “for this function” and recommends the function's own disassembly. Since this operation queried one exact address and there may be no function or instruction to disassemble, use an address/instruction-scoped caveat and recovery instead.
AGENTS.md reference: AGENTS.md:L93-L97
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Already addressed in afa64c7: inspect_native_instruction now attaches the address-scoped ghidraEmptyXrefsLimitation ("no actionable references to this address…") instead of the function-scoped one, so the limitation speaks about the queried instruction address only. The surrounding-disassembly / otool -tV guidance in that text is the address-level cross-check for the empty incoming list.
…tion Greptile review follow-up: inspect_native_instruction checks incoming references to one exact address, so the function-scoped caveat misdescribed the scope; an instruction can be unreferenced while its function has references elsewhere, and the address may have no containing function. Attach the address-scoped xrefs caveat instead.
Analyze-function and annotate-native-function results attached the unresolved-references caveat only when BOTH reference directions were empty, so a dossier with one populated direction presented its empty direction as a collected fact. Split the combined function-references caveat into direction-scoped limitations and attach one per empty direction (analyze_function, annotate_native_function dossier readback, procedure_references by its requested direction).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35396b9961
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (operation === "inspect_native_instruction") | ||
| return isEmptyArray(record.incoming_references) | ||
| ? [ghidraEmptyXrefsLimitation] | ||
| : []; |
There was a problem hiding this comment.
Qualify empty outgoing instruction references
When inspect_native_instruction observes no outgoing references from an instruction, this branch only tests incoming_references. The bridge populates the result's separate references field from instruction.getReferencesFrom() (bridge/ghidra/ReaGhidraBridge.java:1365) and identifies that stream as ReferenceManager observations at line 1448, so under the same miss references: [] is still presented without an outgoing-uncertainty caveat (and a nonempty incoming list suppresses even the address caveat). Check record.references independently and attach an instruction-scoped outgoing limitation.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 70978fd. inspect_native_instruction results carry two independent ReferenceManager facets — the incoming list (visitObservedReferencesTo, entry-point filtered) and the outgoing references built from instruction.getReferencesFrom() (ReaGhidraBridge.java:1365) — and only the incoming list was checked, so a populated incoming list suppressed every caveat while the outgoing facet stayed unqualified.
The branch now qualifies each facet on its own: empty incoming list keeps the address-scoped ghidraEmptyXrefsLimitation; empty outgoing references attaches the new ghidraEmptyInstructionOutgoingLimitation, whose wording notes the instruction's own disassembly as the independent check and deliberately claims no entry-point omission (this stream is not passed through visitObservedReference). Full truth table (both empty / one empty / neither) covered in describe("Ghidra empty instruction reference facets").
inspect_native_instruction results carry two independent
ReferenceManager facets: the incoming list and the outgoing references
built from instruction.getReferencesFrom(). Only the incoming list was
checked, so an instruction with a populated incoming list and no
outgoing references presented the empty outgoing facet as a collected
fact, and any populated incoming list suppressed the caveat entirely.
Each facet is now qualified independently: the empty incoming list
keeps the address-scoped caveat; the empty outgoing list attaches the
new instruction-scoped outgoing limitation (this stream is not
entry-point filtered, so it claims no entry-point omission). Truth
table covered in describe("Ghidra empty instruction reference facets").
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70978fd7d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...(isEmptyArray(record.references) | ||
| ? [ghidraEmptyInstructionOutgoingLimitation] |
There was a problem hiding this comment.
Gate the outgoing caveat on a decoded instruction
When inspect_native_instruction is called for a data, not-in-listing, instruction-interior, or outside-memory address, the bridge takes the instruction == null path and leaves references as [] without ever calling instruction.getReferencesFrom() (bridge/ghidra/ReaGhidraBridge.java:1337-1365). This unconditional empty-array check therefore adds a limitation claiming ReferenceManager found no references “from this instruction” and recommends disassembling it even though the returned status says there is no instruction at the queried address; gate this outgoing limitation on record.status === "decoded" (the address-scoped incoming caveat can still apply).
AGENTS.md reference: AGENTS.md:L93-L97
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 1b82df5: the outgoing limitation now attaches only when status === "decoded". The non-decoded bridges paths (data, not-in-listing, not-instruction-boundary, outside-memory) return before instruction.getReferencesFrom() is ever called, so their empty references is an unobserved facet, not a ReferenceManager observation — attaching the caveat there claimed "no references from this instruction" for an address where no instruction exists. The address-scoped incoming caveat still applies per the empty incoming list (the motivating data-address case).
Non-decoded inspect_native_instruction results (data, not-in-listing, not-instruction-boundary, outside-memory) return before the bridge ever queries instruction.getReferencesFrom(), so their empty references list is an unobserved facet, not an empty ReferenceManager observation. The unconditional outgoing caveat claimed the ReferenceManager returned no references from an instruction that does not exist at that address. The outgoing limitation now attaches only when status is decoded; the address-scoped incoming caveat still applies per the empty incoming list, matching the original motivating data-address case.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b82df5ec9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...(isEmptyArray(record.incoming_references) | ||
| ? [ghidraEmptyIncomingReferencesLimitation] |
There was a problem hiding this comment.
Distinguish filtered internal incoming edges
When an analyzed function has only references originating inside its own body (a self-recursive call is enough), analyzeFunctionObservation collects those and then filters them from incoming_references at bridge/ghidra/ReaGhidraBridge.java:1619-1623. Treating the projected empty array here as a manager miss adds a message that the ReferenceManager returned no actionable incoming references and that no in-product check exists, even though the dossier's outgoing self-edge and procedure_references(incoming) expose that observation; use a dossier-specific caveat that names the internal-edge omission (or propagate the pre-filter count) rather than the generic manager-empty caveat.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed — the dossier's incoming list is in-body-filtered (ReaGhidraBridge.java:1619-1623: incomingReferences = bodyIncoming.stream().filter(ref -> !function.getBody().contains(ref.getFromAddress()))), so a projected empty list can mean "no outside source observed" or "only in-body sources observed", and the generic caveat's "no independent in-product check" claim was wrong for the second case.
Fixed in 47694ca with a dossier-specific incoming limitation (ghidraEmptyDossierIncomingLimitation, used by analyze_function and the annotate_native_function readback): it names the in-body exclusion, points at the outgoing references and disassembly where those edges remain visible, and names procedure_references(incoming) as the in-product discriminator — it reads the same ReferenceManager stream over the body scope without the in-body exclusion, so edges there vs. an empty dossier list distinguish the two cases. procedure_references keeps the generic incoming caveat because its incoming stream is not in-body filtered (verified: procedureReferences → collectReferences(function, direction) unfiltered; only analyzeFunctionObservation filters).
|
|
||
| /** Attached to an empty outgoing-reference facet of a function result. */ | ||
| export const ghidraEmptyOutgoingReferencesLimitation = | ||
| "Ghidra's ReferenceManager returned no actionable outgoing references for this function in this session. An empty outgoing list reflects what this analysis resolved, not proof that the function references nothing; synthetic entry-point references are omitted. The function's own disassembly is an independent check for direct outgoing references before concluding there are none."; |
There was a problem hiding this comment.
Provide an external-function recovery path
When procedure_references(outgoing), analyze_function, or annotation readback targets an external/imported function with an empty body and returns no outgoing edges, this text is appended even though the recommended "function's own disassembly" does not exist. This leaves users with an impossible recovery path for common import symbols; inspect procedure.classification.external and either explain that the defining artifact is required or avoid the local-disassembly recommendation.
AGENTS.md reference: AGENTS.md:L93-L97
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 47694ca: records whose procedure.classification.external is true now get an external-specific outgoing limitation (ghidraEmptyExternalOutgoingLimitation) instead of the local-disassembly text. It explains that the defining body is not part of this program database, so the outgoing list cannot describe what the function references, and names the real checks: this program's call sites (the function's incoming references and callers) and the defining artifact. Applied across procedure_references(outgoing), analyze_function, and the annotate_native_function readback; the non-external outgoing caveat is unchanged.
Two unqualified cases remained in the function-reference caveats: - The analyze_function/annotation dossier excludes incoming references whose source is inside the function's own body (a self-recursive call is enough), so the projected empty list can mean 'no outside source observed' or 'only in-body sources observed'. The dossier now uses a dedicated incoming limitation naming the exclusion, pointing at the outgoing edges/disassembly where in-body edges remain visible, and at procedure_references(incoming) - the same ReferenceManager stream without the in-body exclusion - as the in-product discriminator. procedure_references keeps the generic incoming caveat: its incoming stream is not in-body filtered. - An external function has no local body, so the outgoing caveat's 'function's own disassembly' recommendation was impossible. Records classified external now get an external-specific outgoing limitation naming the defining artifact and this program's call sites instead (procedure_references outgoing, analyze_function, annotation readback).
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47694cad11
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| * dossier, which excludes sources inside the function's own body. | ||
| */ | ||
| export const ghidraEmptyDossierIncomingLimitation = | ||
| "Ghidra's ReferenceManager observed no incoming references from outside this function's body in this session. The dossier's incoming list excludes sources inside the body (a self-recursive call is one), so an empty list can also mean the only observed sources are in-body; those edges remain visible in the outgoing references and disassembly, and procedure_references(incoming) reads the same ReferenceManager stream without the in-body exclusion to distinguish the two cases. Sources outside the program's observed references still require an external scan (for example otool -tV, pairing adrp with add or ldr) before concluding there are none."; |
There was a problem hiding this comment.
Preserve filtered synthetic references in the dossier caveat
When the only incoming item to a function from outside its body is Ghidra's synthetic entry-point reference, the ReferenceManager returns it but visitObservedReference discards it before the dossier's body filter (bridge/ghidra/ReaGhidraBridge.java:1619-1622,3972-3974), so this sentence falsely says the manager observed none. Fresh evidence after the earlier actionable-reference wording fix is that the newly added dossier-specific string reintroduces that unqualified claim; say “no actionable ...” and retain the synthetic-entry omission so an empty dossier does not erase what was filtered.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in ce1a286. Verified against the bridge: visitObservedReference (ReaGhidraBridge.java:3973-3974) drops entry-point references while collectReferences walks the body addresses, upstream of the in-body filter at lines 1619-1621 — so the dossier's incoming list can be empty even when the ReferenceManager returned a synthetic entry-point reference. The caveat now reads "returned no actionable incoming references from outside this function's body", states that synthetic entry-point references are omitted before the dossier's body filter and that in-body sources are excluded, and corrects the recovery claim you flagged earlier findings converged on: procedure_references(incoming) reads the same stream without the in-body exclusion but omits synthetic entry-point references as well, so it separates the in-body-source case only, not the entry-point one. Facet-attachment tests are unchanged and green (they compare via the imported constant, so no test text pins the old wording).
The dossier-specific incoming caveat claimed the ReferenceManager observed no incoming references from outside the body, but visitObservedReference (ReaGhidraBridge.java:3973-3974) drops entry-point references before the body filter (1619-1621), so the manager may have returned references the dossier never reports. Reframe as 'returned no actionable' and name both omissions; correct the recovery claim: procedure_references(incoming) lacks the in-body filter but omits synthetic entry-point references as well.
|
Welcome to REA, @pijalu, and thanks for addressing the ambiguity in empty Ghidra reference results. Scoped caveats help callers distinguish “not resolved here” from evidence that no references exist. |
Problem
xrefsreturned[]for every address inFM9-Edit-arm64(16 MB, arm64 Mach-O), including string addresses that demonstrably exist (DISTORT_BASSat0x1005409a2).procedure_callersworks on the same binary, so the call graph is intact — it is the reference manager that resolves nothing.The empty result carried no diagnostic distinguishing "no references" from "this provider resolved no references in this target", so it read as a real answer: callers concluded an address is unreferenced when Ghidra's analysis simply resolved nothing.
Fix
GhidraProviderClient.projectExecutionattaches unresolved-references caveats to empty ReferenceManager observations via one owner (emptyReferenceCaveat):xrefslist, and an empty incoming-reference list ininspect_native_instructionfor the queried address, attachghidraEmptyXrefsLimitation:referenceslist on a decodedinspect_native_instructionresult (built frominstruction.getReferencesFrom(), a ReferenceManager stream that is not entry-point filtered) attachesghidraEmptyInstructionOutgoingLimitation. Non-decoded statuses (data, not-in-listing, not-instruction-boundary, outside-memory) return before the bridge queries the ReferenceManager, so their empty list is never caveated as an observation:procedure_referencesby its requested direction,analyze_functionper empty direction, andannotate_native_functionfrom its dossier readback. Records whoseprocedure.classification.externalis true get external-specific wording; the rest:ghidraEmptyIncomingReferencesLimitationforprocedure_references(its incoming stream is not in-body filtered):ghidraEmptyOutgoingReferencesLimitation:ghidraEmptyExternalOutgoingLimitation(an external function has no local body, so the local-disassembly recommendation would be impossible):The wording reports the observation (no actionable references returned) rather than claiming the ReferenceManager resolved nothing — the bridge filters synthetic entry-point references before observation, so "resolved no references" would be false when only entry-point references existed. No recovery path is recommended beyond the disassembly:
trace_featureobservesxrefsper matched string, so on this failure it repeats the same lookup rather than independent evidence.Non-empty results carry no caveat. Cache invalidation:
instruction_referencesbumps toexact-address-incoming-without-synthetic-entry-v3andfunction_referencestocomplete-body-and-entry-reference-manager-v3insharedAnalysisSemantics, so analysis snapshots captured before this change no longer satisfy the profile commitment and their bare empty results are not replayed as current (raw profile digests recomputed). The bridge andvisitObservedReferencesToare unchanged; the diagnostic is provider-level Evidence metadata.Tests
src/ghidra/GhidraProvider.behavior.test.ts:describe("Ghidra empty reference diagnostics")— empty xrefs →ghidraEmptyXrefsLimitation, non-empty → absent; emptyprocedure_referencesper direction → the matching direction limitation (and not the opposite one); external procedure with empty outgoing →ghidraEmptyExternalOutgoingLimitation; non-empty → neither.describe("Ghidra empty function-reference facets")—analyze_functionwith both directions empty → dossier-incoming + outgoing limitations (and not the generic incoming one); incoming-only-empty →ghidraEmptyDossierIncomingLimitationonly; outgoing-only-empty → outgoing limitation only; external function with both empty → generic incoming +ghidraEmptyExternalOutgoingLimitation, without the dossier-incoming or local-disassembly text.describe("Ghidra empty annotation reference facets")—annotate_native_functiondossier readback: both directions empty → both limitations, one direction populated → that direction's limitation only.describe("Ghidra empty instruction reference facets")— full truth table forinspect_native_instruction: both facets empty → both limitations; incoming-only empty → address limitation only; outgoing-only empty on a decoded instruction → instruction-outgoing limitation only; both populated → neither; non-decoded data address → address caveat per its incoming list only, never the outgoing one.src/ghidra/GhidraSnapshotCache.test.ts— profile-admission cases: snapshots bound toinstruction_referencesv2/v1 orfunction_referencesv2 (or missing keys) are refused withEvidenceIntegrityErrorbefore any dispatch.tsc --noEmitclean;src/ghidra/green (1105 tests across 34 files).Validation (real terminal output)
Validated live against the initial caveat build; the subsequent changes reword the text, generalize the attach rule per direction and facet (function directions, annotation readback, instruction incoming/outgoing), and add semantics bumps — the attach/not-attach behavior tests cover the current strings.
Workaround note (unchanged): call sites can still be recovered from
otool -tVby pairingadrp xN, <page>withadd xM, xN, #<imm>/ldr …, [xN, #<imm>]and computing the target address.Author readiness
Human owner: @pijalu