Skip to content

feat(ghidra): fail fast on oversized decompiler bodies - #10130

Open
harborbayco wants to merge 1 commit into
morluto:mainfrom
harborbayco:decompile-fail-fast
Open

harborbayco wants to merge 1 commit into
morluto:mainfrom
harborbayco:decompile-fail-fast

Conversation

@harborbayco

Copy link
Copy Markdown

What

Bodies beyond a 64 KiB ceiling are refused before the decompiler starts, with a dedicated decompile_oversized code reporting measured size and limit. analyze_function records the refusal under facet_availability.pseudocode like 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_function dossier, instruction ranges via rea 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

  • Behavior test projecting decompile_oversized (139/139 in the Ghidra provider suite at authoring; 286/286 green in the full provider file after rebase onto current main, with your new bridge-limit test kept intact alongside)
  • Bridge compiles clean against Ghidra 12.1.4 jars
  • Threshold from campaign evidence: ~26 KiB decompiles reliably; 94 KiB and 171 KiB failed after ~9 CPU-minutes each

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T18:16:41.735708Z a86b378 PR opened
ℹ️ 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 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: 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".

Comment on lines +1529 to +1533
if (failure.kind === "remote" && failure.remoteCode === "decompile_oversized")
return new AnalysisResourceConstraintError(
operation,
"cpu",
failure.message,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +3748 to +3750
"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."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +1537 to +1538
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.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 22, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@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.
cc @gensokyo-dev @dandgabr

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@harborbayco also, this branch has merge conflicts with main — please resolve those along with the open threads.

This branch has not been deployed

No deployments
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 enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants