Skip to content

fix(ghidra): keep listing facts when one function fails to decompile - #4650

Merged
gensokyo-dev merged 8 commits into
morluto:mainfrom
RishTheFish21:fix/ghidra-decompiler-failure-dossier
Oct 20, 2026
Merged

gensokyo-dev merged 8 commits into
morluto:mainfrom
RishTheFish21:fix/ghidra-decompiler-failure-dossier

Conversation

@RishTheFish21

@RishTheFish21 RishTheFish21 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4644. When one Ghidra function fails to decompile, analyze_function now returns its listing-backed dossier with pseudocode, native API and p-code value flow explicitly unavailable and the decompiler's reason preserved. Assembly, comments, callers/callees, references, strings/names, CFG and relationship coverage remain available. Cancellation still ends the request. procedure_pseudo_code still fails, with procedure-specific recovery advice instead of blaming environment readiness.

Keep @RishTheFish21's production fix. Qualification merges current main 052956af3, selects exact exported entries in the native probe, binds the Linux fixture's local calls, supervises compiler cleanup and requires positive lineage evidence before reporting cleanup complete. Reports now retain target/source/bridge digests and the provider/profile identity. The actual comparison contains eight focused files.

Contract and scope

The Ghidra bridge owns the unavailable-facet interpretation; the provider adapter projects its named error. CLI and MCP use the existing shared function workflow and dossier schemas. The bridge digest already versions analysis profiles. Existing read-only provider authority applies; additional maintainer scope decision is not applicable. Public schemas and read-only authority remain unchanged. A result-specific live policy prevents replay of transient failures in direct and composed snapshots; healthy caching remains enabled.

Executed validation

Linux x64; pinned Node 24.18.0 / npm 11.16.0; BYO Ghidra 12.1.4 / JDK 21:

  • Base provider projection: 1 regression failed. Candidate: 250 focused tests passed across provider projection, parsed contracts, snapshot recovery/import, shared workflow policy, verifier cleanup and MCP native API workflows, plus the earlier 8 relationship-coverage tests.
  • Real Ghidra with the main bridge and controlled decompiler failure: RequestFailure: Ghidra decompilation failed: Injected backend failure; the requested dossier is lost. With the candidate bridge, 34 checks passed. All listing facets and availability/relationship coverage match the healthy observation; decompiler facets retain the failure reason; pseudocode-only failure, cancellation and session recovery remain covered. The probe invokes the actual request response producer; both the native response and parsed observation mark transient failures live. The degraded dossier passes the real provider output contract; the healthy path also passes through the authenticated TCP provider.
  • Linux source-owned ELF fixture: 23 assembly lines, 1 caller, 1 callee, 7 blocks retained after failure. Target SHA-256 f8b25a00da8a04575cc5dc78fe737f5589cc99d2e6733f6dca7bf20379ada5f2; source/bridge digests and compiler arguments are emitted by the verifier.
  • Public MCP on the installed /usr/bin/true ELF, 35,664 bytes, SHA-256 c79bf44242829108e323378531f4ac839513ca1fba45efd6583643526e1e9fd2: select a provider-returned entry address, analyze twice in one session, verify identical normalized dossiers, export complete Evidence, close and verify immutable input/empty temporary roots. Protocol 2026-07-28.
  • Review regressions: a stopped failed compiler leaked its workspace before the fix; controlled incomplete/unknown cleanup retains it. The actual supervised failed-compiler control preserves exit-6 diagnostics and removes the workspace. Degraded direct/composed observations retain Evidence, skip replay entries, and observe recovery; healthy repeats still hit cache.
  • Final CI: source tests, package build and docs passed. Static/portable/required gates fail on main-existing duplication and EVM tests; cancelled shards are not claimed as passing. Latest Codex review: no findings; Greptile: 5/5.
  • Final formatting follow-up: the pre-commit lint fix changed a test after formatting; corrected it and passed format:check after the corrective commit. Runtime/native verification remains applicable because that follow-up only formats a test fixture.
  • Pre-push check:fast, full npm run check (typecheck, formatting, lint, knip, metadata/module/architecture guards), and npm run docs:check: passed; the documentation check also passed 5 consistency tests.

Initial Linux probe attempts stopped before the injected failure: PLT name ambiguity, then the fixture's ELF symbol interposition invalidating its direct-call expectations. Those are retained as harness diagnostics, not bug reproductions. Exact exported-address selection and explicit Linux local binding fix the producing fixture. A later stronger-handler attempt stopped at missing nested headless context before fault comparison; the final probe binds the actual HeadlessAnalyzer as Ghidra does for nested scripts, then passes all 34 checks. Native disassembly independently verifies the direct calls. The successful main/candidate fault comparison uses the corrected fixture.

Performance and limits

One CPU; 8-GiB hard / 7-GiB early family-memory stop; no swap. 34-check real conformance: 76.952 s elapsed, 74.492 s family CPU, 570.0 MiB peak. The probe uses the real request handler and positive lineage cleanup. Public real-ELF MCP task: 38.007 s elapsed, 36.655 s CPU, 1,100.7 MiB peak. Cold import/search 29.553 s; first function 181.1 ms, repeated warm dossier 29.6 ms. All completed with positive cleanup evidence and no OOM. OS cache is uncontrolled; these samples do not establish a general speedup. The failed baseline does not complete the same dossier task, so its failure time is not an equivalent latency comparison. The previous-head equivalent task measured 38.936 s / 37.550 CPU s / 1,116.6 MiB (174.5 ms first / 24.4 ms warm); single samples do not establish a performance change. Only transient failures opt out of existing caches.

Captured post-connect MCP traffic for six tool calls: 21,908 cl100k_base token estimate (519 outbound / 21,389 inbound; previous head 21,905). SDK initialization/startup catalog or schema traffic was not captured; actual agent/model usage and prompts are unmeasured. This is neither a whole-task token total nor a token-savings claim.

The decompiler failure is injected into a real Ghidra program; a naturally failing public binary is unavailable. The degraded public CLI with a real backend and Windows were not run. Controlled-wire MCP tests exercise degraded composed output and cache recovery; simulated failures do not establish natural decompiler failure conditions. The public real-ELF MCP control is healthy. Prior contributor macOS evidence predates this Linux qualification and was not rerun here. Target code is never executed.

Author readiness

Human owner: @RishTheFish21

The original readiness declaration is retained. The agent qualified the final diff for @gensokyo-dev under the task owner's explicit delegation to validate, update ready PRs and merge; no new separate human review by the original author is claimed.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • Focused existing-boundary fix; applicable scope/authority resolved; artifact identity, partial facts and exact cleanup owners preserved.
  • Final diff checked for unrelated changes/credentials; generated binaries, projects, local reports and dependencies remain outside the diff.
  • Final local checks and final-head automated review complete (Codex: no findings; Greptile: 5/5).
  • Merged as c374c2fe7290b914d73d9e27af38b498753ec593 with the task owner’s authorization to leave unrelated CI failures unchanged. Exact CI main already fails duplication (3.52498% > 3.5%; exact PR merge 3.52671%). The two failing EVM cancellation/cleanup cases also reproduce on that main; four other shards were cancelled, so their coverage is unavailable. No unrelated changes or threshold adjustments. See the controlled attribution.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T11:55:12.162958Z 364753c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new actionable defect was found.

Summary

Keeps Ghidra’s listing-backed function facts when decompilation fails.

  • Ghidra function analysis keeps listing facts when decompilation fails.
  • Failed decompiler results are retried instead of replayed.
  • Pseudocode-only failures point callers to the function dossier.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Analyze function] --> B{Decompilation result}
  B -->|Success| C[Full dossier]
  B -->|Failure| D[Listing-backed dossier with failure reason]
  B -->|Cancellation| E[End request]
  C --> F[Retain Evidence and allow caching]
  D --> G[Retain Evidence and skip caching]
  G --> H[Pass live policy to composed workflows]
Loading

Reviews (6) · Last reviewed commit: "test(ghidra): format transient workflow ..." · Reviewed by Greptile

@RishTheFish21

Copy link
Copy Markdown
Contributor Author

CI status on this branch: the PR's own checks pass, but the last three CI runs each failed in a different test this PR doesn't touch.

  • Run 1 (shard 2): verifierFileResources "Ghidra verifier probes await the shared owned inspection contract". Caused by this PR's new lane calling inspectGhidraInstallation directly. Fixed in f1aa193 (now awaits inspectVerifierGhidraInstallation).
  • Run 2 (shard 3): tests/acceptance/process/processFinalization.test.ts "retains finalization facts with omitted digests and cleans the owned descendant". Only cleanup_outcome differed; the test took 5.2s against a 1.5s finalization window.
  • Run 3 (shard 4, run 39338614098): tests/acceptance/applications/keyedArchiveScalarKinds.test.ts "keeps CFPropertyList's non-finite real spellings in an XML keyed archive". open_binary failed with cleanup_incomplete from the Ghidra Java prerequisite probe (operation ghidra:java, stage cleanup, pid 5357) on the runner's Temurin 17, before the keyed-archive check ran.

None of these touch the decompiler bridge or GhidraProviderClient paths changed here.

@gensokyo-dev

Copy link
Copy Markdown
Collaborator

@codex review

Please review current head e605975 against current main. The refreshed comparison has eight focused files. Executed Linux evidence: 153 related TypeScript tests, real Ghidra controlled failure/recovery (32 checks), and public MCP on a real installed ELF with retained Evidence and verified cleanup. Natural failure inputs and degraded CLI/MCP projection remain explicitly unverified; full checks/CI are in progress.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6059750ec

ℹ️ 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".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
@gensokyo-dev

Copy link
Copy Markdown
Collaborator

@codex review
Please review latest head d442c55. Both valid findings are addressed: typed compiler cleanup ownership and producer-owned transient cache veto, including composed CLI/MCP snapshots. Evidence remains retained and healthy cache reuse is unchanged. Validation and limits are current in the PR body.

@gensokyo-dev

Copy link
Copy Markdown
Collaborator

CI attribution for latest head 364753c57: the earlier hook-induced formatting issue is fixed and the post-commit full formatting check passed. The remaining static-check failure is the duplication gate on current main.

Exact tree Duplicate lines Gate (3.5%)
PR head 364753c57 (source base 052956af3) 3.40634% pass
CI base/main ee12d517a 3.52498% fail
Exact CI merge b861635d5 3.52671% fail

Executed bounded local checks reproduce these results with identical package, lockfile, detector configuration and report-runner digests for main and the CI merge. Main already fails without this PR. No threshold adjustment or unrelated refactor is included. Production/native/MCP verification is current in the body; the final follow-up only formats the workflow regression fixture.

@gensokyo-dev

Copy link
Copy Markdown
Collaborator

Portable-test attribution is now verified on both exact trees: main ee12d517a and CI merge b861635d5 each run the four captured-warning lifecycle scenarios with 2 passed / 2 failed. Both fail late-cancellation with Expected lifecycle failure and cancelled-cleanup-failure with the provider cleanup error, matching CI shard 5. The EVM provider, failure mapper and test file have identical SHA-256 digests across both trees. Both bounded controls confirm process cleanup and no OOM. These failures already exist on main; no EVM change is included. Four other CI shards were cancelled and are not claimed as passing. Latest-head Codex review has no findings; Greptile is 5/5.

@gensokyo-dev
gensokyo-dev merged commit c374c2f into morluto:main Oct 20, 2026
32 of 40 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026
3 tasks done
taiqi-dev added a commit to taiqi-dev/rea that referenced this pull request Oct 26, 2026
Adapt upstream morluto#5356, morluto#4650 and morluto#5662 to the Windows fork. Preserve listing facts and live retry policy, carry explicit settings into client setup, and qualify natural timeouts with a source-owned Windows DLL. Windows acceptance, default real-provider checks and SDK schema regressions passed; details in the verification record.
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Ghidra: one decompiler failure discards the whole analyze_function dossier and is reported as an environment problem

3 participants