Repository navigation
feat(ghidra): fail fast on oversized decompiler bodies - #10130
harborbayco wants to merge 1 commit into
Conversation
Bodies beyond a 64 KiB ceiling exhaust Ghidra's decompiler restart budget after several CPU-minutes and surface as a generic execution failure whose remediation says an unchanged retry will not succeed — accurate but not actionable. The bridge now refuses such bodies before starting the decompiler with a dedicated decompile_oversized code reporting the measured body size and the limit, and analyze_function records the refusal under facet_availability.pseudocode like other decompiler unavailability while keeping listing, reference and CFG facts. The client maps the new code to a resource-constraint projection whose remediation names the concrete alternatives: analyze_function for the dossier, instruction ranges via rea instructions, or the smaller callers and callees that hold the logic of interest. Validation: new behavior test projecting decompile_oversized (139/139 in the Ghidra provider suite); bridge compiles clean against the installed Ghidra 12.1.4 jar set. Threshold derived from campaign evidence: bodies through ~26 KiB decompiled reliably; 94 KiB and 171 KiB bodies failed after ~9 CPU-minutes each.
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a86b378c1d
ℹ️ 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 (failure.kind === "remote" && failure.remoteCode === "decompile_oversized") | ||
| return new AnalysisResourceConstraintError( | ||
| operation, | ||
| "cpu", | ||
| failure.message, |
There was a problem hiding this comment.
Preserve cancellation state for oversized failures
When an AbortSignal fires after the bridge returns this remote error but before the active request settles, GhidraRequestQueue records concurrentCancellation and closes the session; this branch constructs the resource error directly instead of passing the failure through ghidraRequestOutcome. The projected message therefore omits that the next request must start a new session (and, without cancellation, also omits the retained-session fact), even though its remediation tells the caller to invoke analyze_function; route this failure through the same outcome handling as the other request-level decompiler failures.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
| "Ghidra decompiler body limit: function body is " + bodyBytes + | ||
| " bytes (limit " + MAX_DECOMPILE_BODY_BYTES + "). Bodies beyond this limit" + | ||
| " exhaust the decompiler's restart budget; fail fast instead of burning it." |
There was a problem hiding this comment.
Label the restart-budget claim as a policy inference
For any body just over 64 KiB, this diagnostic states that the function exhausts the restart budget even though the calibration comment only describes failures in the 100 KiB range and this branch deliberately never invokes the decompiler. The text is propagated into direct errors and analyze_function facet availability as if it were an observation about this procedure, so report the measured body and fixed ceiling while labeling exhaustion as the policy rationale/inference rather than a per-function result.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
| remediationAction: | ||
| "The function body exceeds the decompiler's fail-fast ceiling, so the decompiler was not started. Call analyze_function (CLI: `rea function`) for the same procedure: it returns assembly, callers, callees, references and basic blocks from the Ghidra listing and records the oversized body under facet_availability.pseudocode. For pseudocode-shaped evidence on very large functions, read instruction ranges with `rea instructions` or inspect the smaller callers and callees that hold the logic of interest. Repeating the unchanged decompile request is not expected to succeed.", |
There was a problem hiding this comment.
Identify the ceiling as non-configurable in recovery
For an oversized function, callers can see the supported ghidra.decompile_timeout_seconds and ghidra.decompile_max_payload_mib controls, but this action only says an unchanged retry fails, so changing either still looks like a viable recovery even though the hard-coded Java ceiling ignores both. State explicitly that this release has no runtime override for the body ceiling and that timeout/payload settings do not raise it, as required for an actionable fixed-limit recovery.
AGENTS.md reference: AGENTS.md:L97-L100
Useful? React with 👍 / 👎.
| * 100 KiB range and above exhaust it after several CPU-minutes. The | ||
| * listing, reference and CFG facts stay available via other operations. | ||
| */ | ||
| private static final long MAX_DECOMPILE_BODY_BYTES = 65536; |
There was a problem hiding this comment.
Update the product docs for the new per-operation ceiling
This constant adds a fixed refusal for every decompile body over 64 KiB, but docs/getting-started/installation.md lines 1415-1420 still say Ghidra operations have no fixed per-operation ceiling and that an absent timeout leaves decompilation unbounded. Users following the provider setup guide therefore receive the opposite contract and cannot anticipate the new resource_constraint; document the threshold, the direct-decompile failure, and the partial dossier recovery in the same change.
AGENTS.md reference: AGENTS.md:L99-L103
Useful? React with 👍 / 👎.
|
@harborbayco thanks for the PR — there are 4 open review threads here:
Could you address or reply to these? Once they're resolved and CI is green we can take another look. |
|
@harborbayco also, this branch has merge conflicts with |
What
Bodies beyond a 64 KiB ceiling are refused before the decompiler starts, with a dedicated
decompile_oversizedcode reporting measured size and limit.analyze_functionrecords the refusal underfacet_availability.pseudocodelike other decompiler unavailability while keeping listing, reference and CFG facts; the client maps it to a resource-constraint projection whose remediation names the concrete alternatives (analyze_functiondossier, instruction ranges viarea instructions, smaller callers/callees).Why
Without it, oversized bodies exhaust Ghidra's decompiler restart budget after several CPU-minutes and surface as a generic execution failure whose remediation says an unchanged retry won't succeed — accurate but not actionable. This converts a slow opaque death into a fast, specific, partially-useful result.
Validation
decompile_oversized(139/139 in the Ghidra provider suite at authoring; 286/286 green in the full provider file after rebase onto currentmain, with your new bridge-limit test kept intact alongside)