Repository navigation
fix(ghidra): warn when callee/caller reads stop at a truncated function body - #2360
Conversation
…on body procedure_callees and procedure_callers returned a bare address list, so an inferred no-return call that truncates Ghidra's function body silently dropped real edges (fixes morluto#2326). Wrap both views in the function-observation envelope with noReturnCallLimitations, matching procedure_info, procedure_assembly, procedure_pseudo_code, read_function_instructions, and analyze_function (precedent: 69a8b3a). Version the boundary-observation contract to ghidra-terminal-call-limitations-v2 so older snapshots cannot replay unqualified results. Validation: red->green unit test for the envelope requirement, MCP boundary evidence test extended for both views (limitations retained through Evidence and snapshot replay), 8 harness test files + ghidra behavior tests green, check:fast, docs:check, verify:test-discovery green. Real Ghidra host lane unavailable here (no Ghidra installed); Java change mirrors the existing procedureInfo call pattern.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
926bd5b to
d9d39ef
Compare
|
TL;DR: This PR works on real Ghidra. The callee and caller reads now carry the same terminal-call line as I filed #2326. Thanks, sx4im, for the quick fix. I ran head d9d39ef and base 3ee6ff4 on real Ghidra 12.1.4 over MCP. The target was a stripped Results
On head, callee and caller reads match Cause B and callers#2326 asks for cause B as its own line, so I see it as a follow-up to this PR. For cause B only, head stays silent in 33 of 44 functions. In the other 11, the line names a different call, so it does not explain the cut. A missing caller is lost in the caller's body, but the read checks the target's body. In 12 cases a real caller was missing. No head read carried that caller's line. #2326 said a read on the target can't see it. TestsThe PR's 3 test files pass on Node 22.23.1, 24.18.0 and 26.11.1, with 96 tests each. On base, with only the PR's test changes copied in, 4 tests fail and 92 pass. The 4 are the 2 new envelope tests, the relationship-coverage fixture and the v2 profile check. Not run
Table of 62 functions: 18 cause A, 16 cause B, 28 with no call lostCause is the kind of gap in front of each lost call. A is a gap after a listed no-return call. B is a gap after a return or jump. Real calls come from objdump on the unstripped file. Returned is the size of the head callee list. Info lines is the count of terminal-call lines in
Callers: 12 cases with a missing callerThe first ten are the 10 targets from #2326. The last two are missing callers I found among the 50 functions there. In all 12, the call sits outside the caller's body. Target's own lines is the count in the target's
Call graph and trace: 6 casesThe lines appear in the result's
Commands
Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@greptileai review |
|
This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on. |
|
Summary
Fixes #2326.
procedure_calleesandprocedure_callersreturned a bare address list. When an inferred no-return call truncates Ghidra's analyzed function body, real call and caller edges outside the body were silently dropped with no warning. Both views now return the function-observation envelope (value+limitations) carryingnoReturnCallLimitationsnotes, the same treatment the five other function views got in 69a8b3a.Problem and expected behavior
Smallest trigger: read
procedure_calleesfor a function whose body Ghidra cut short at an inferred no-return call. Before: the response carried the surviving edges only and no caveat, so a caller could not tell edges were missing. The provider design places such caveats inlimitations. Expected: terminal-call observations appear in Evidence limitations for these two views, exactly as they already do forprocedure_info,procedure_assembly,procedure_pseudo_code,read_function_instructions, andanalyze_function.Change and scope
bridge/ghidra/ReaGhidraBridge.java:procedureCallsnow returnsfunctionObservation(result, noReturnCallLimitations(...))over the same instruction listingprocedureInfouses. No new helpers; the existing helper is reused verbatim.src/ghidra/GhidraFunctionValues.ts:procedure_calleesandprocedure_callersjoinfunctionBoundaryObservationOperations, so the TS parser requires the envelope and surfaces its limitations into Evidence.src/ghidra/GhidraAnalysisProfile.ts: boundary-observation contract versioned toghidra-terminal-call-limitations-v2, so older unqualified snapshots cannot replay.src/contracts/officialToolContracts.tsanddocs/ghidra-provider.md: document the limitation for these views.Contribution scope fit: ordinary fix within existing boundaries; no new capability, no execution or mutation behavior. Maintainer scope decision: not applicable.
Contract and boundary impact
procedure_callees/procedure_callers(bare array to{value, limitations}); TS parser is the only consumer and expects the new shape. Other providers untouched.Expected effects:
Evidence and regression coverage
src/ghidra/GhidraFunctionValues.test.ts: new red-green test requiring the envelope for both operations (bare array rejected; envelope with limitations preserved). Test-local operation set updated.tests/boundary/mcp/ghidraEvidenceMcp.test.ts: terminal-call qualification test extended toprocedure_callees/procedure_callers, proving limitations flow through Evidence and snapshot replay.tests/boundary/mcp/ghidraMcpHarness.tsandsrc/ghidra/GhidraProvider.behavior.test.ts: bridge fixtures updated to the envelope shape.ok: true) and passes after. No Ghidra host available here, so no real-provider reproduction of a truncated body; the Java change is a mechanical wrap identical to the existingprocedureInfocall pattern.verify-real-ghidra-function) not run locally; the Java-side wrap is unverified against a live bridge beyond matching the established pattern.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/ghidra/GhidraFunctionValues.test.ts— 43 passed (new envelope test red before, green after)npm run test:focused -- tests/boundary/mcp/ghidraEvidenceMcp.test.ts src/ghidra/GhidraProvider.behavior.test.ts— 53 passedanalysisViewMcp,ghidraCompactReferencesMcp,ghidraFailureDiagnostics,ghidraInventoryMcp,ghidraNativeApiMcp,ghidraRoutingMcp,inlineEvidenceCompositionMcp,ghidraEvidenceMcp) — 25 passednpm run check:fast— typecheck + lint successfulnpm run docs:check— passednpm run verify:test-discovery— 982 test files discovered exactly oncefix/2326-ghidra-truncated-body-warningsat 926bd5b, tree 378c4f4 identical to local commit, parent fd95880 (upstream main).Compatibility, safety, and release
{value, limitations}; the in-repo TS parser is updated in the same change. No migration for callers of the MCP/CLI surface, where the value schema is unchanged.Before merge
type(scope): outcome.