Skip to content

analysis: prune error(nonzero) call fall-through — stop the boundary overrun (closes ~50% of the Ghidra GED gap) - #138

Merged
mahaloz merged 1 commit into
mainfrom
feat/error-noreturn-overrun
Jul 6, 2026
Merged

mahaloz merged 1 commit into
mainfrom
feat/error-noreturn-overrun

Conversation

@mahaloz

@mahaloz mahaloz commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

A 22-agent investigation of why kuna loses to Ghidra proper found ~50% (11/22, all the biggest margins) are one bug: glibc error(status,…) is conditionally no-return (calls exit() when status != 0), and kuna didn't prune the post-call fall-through. So the flow-follower walked past call error(nonzero), over the NOP pad, into the next function's prologue and decompiled both as one blob — expr/docolon absorbed all of eval6 (561 LOC vs Ghidra's 140); split/bytes_chunk_extract swallowed five functions. Absorbing a foreign CFG maximally inflates node/edge counts → the catastrophic GED margins.

The wiring gap

kuna already recognised error(nonzero) (the ErrorRecognizer/noreturn_error, DIV-16) but only committed it function-entry-keyed (concludes a wrapper no-return — helps callers). This adds the missing per-call-site prune, exactly as Ghidra's discovered-no-return analyzer does:

  • s1_noreturn_propagate collects every call error(nonzero,…) site (AnalysisOutput::no_fallthru_calls),
  • the commit stashes them on Architecture::error_noreturn_callsites,
  • decompile-all applies them as CALL_RETURN flow overrides — the mechanism was fully ported but nothing fed it.

Effect (decompile-all)

function before after Ghidra
expr/docolon 561 133 140
tr/read_and_delete 374 41 ~40
split/bytes_chunk_extract 446 62 —
nl/build_type_arg 351 35 —
cat/simple_cat 286 23 —

Pure port-fidelity (kuna now does exactly what Ghidra does — no readability trade-off).

Safety

Gated by the existing noreturn_error + listing, so the datatest/console parity paths (no Listing) are byte-identical. make test 675/675 PARITY OK, make test-stages 254/254 PARITY OK, make rust-test green. New regression test decompile_all_error_nonzero_does_not_absorb_next_function.

🤖 Generated with Claude Code

https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J

…boundary overrun (close ~50% of the Ghidra GED gap)

A 22-case multi-agent investigation of where kuna loses to Ghidra proper found that
~50% (11/22, all the biggest margins) are ONE bug: glibc error(status,…) is conditionally
no-return (calls exit() when status != 0), and kuna did not prune the post-call fall-through.
So the flow-follower walked past `call error(nonzero)` over the NOP pad into the NEXT
function's prologue and decompiled both as one blob — expr/docolon absorbed all of eval6
(561 LOC vs Ghidra's 140); split/bytes_chunk_extract swallowed FIVE functions. Absorbing a
foreign CFG maximally inflates node/edge counts -> the catastrophic GED margins.

kuna already recognised error(nonzero) (the ErrorRecognizer / noreturn_error, DIV-16) but
only committed it FUNCTION-ENTRY-keyed (concludes a wrapper no-return, helps callers). This
wires the missing per-CALL-SITE prune, exactly as Ghidra's discovered-no-return analyzer does:
 - s1_noreturn_propagate collects EVERY `call error(nonzero,…)` site (AnalysisOutput::no_fallthru_calls),
 - the commit stashes them on Architecture::error_noreturn_callsites,
 - decompile-all applies them as CALL_RETURN flow overrides (the mechanism was fully ported
   but nothing fed it).

Effect (decompile-all): docolon 561->133 LOC, tr/read_and_delete 374->41, split/bytes_chunk_extract
446->62, nl/build_type_arg 351->35, cat/simple_cat 286->23 — all now Ghidra-like. Pure
port-fidelity (no readability trade-off). Gated by the existing noreturn_error + listing, so the
datatest/console parity paths (no Listing) are byte-identical.

Gates: make test 675/675 PARITY OK, make test-stages 254/254 PARITY OK. New regression test
decompile_all_error_nonzero_does_not_absorb_next_function (err_fatal must not absorb compute).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant