Repository navigation
[AUTOMATED] fix(p1): noreturn_discstrict — a decode failure is not evidence that a callee never returns (DIV-92) - #344
Merged
Conversation
…a callee never returns (DIV-92) [AUTOMATED] `noreturn_disc` concludes a callee no-return once >=3 of its call sites "show no valid fall-through", and one of the three arms implementing that test is `!listing.is_instruction_start(fall)`. That arm does not mean what its name says. `listing/walk.rs` pushes EVERY call's fall-through onto the per-function instruction worklist unconditionally, and that worklist drains before the function is left, so a call's successor is always ATTEMPTED; it fails to become an instruction start in exactly three ways -- `decode_one` returned `Err`, the decode was zero-length, or the address is outside every executable range. The Listing records no decode outcome (a failed decode and an unvisited byte are the same `Undefined` code unit), so the arm is precisely and only a DECODE-FAILURE DETECTOR: a fact about kuna's SLEIGH coverage, feeding a rule that removes code. Three undecodable bytes are enough to conclude that `mov $7,%eax ; ret` never returns, after which the flow layer deletes the live tail of every caller. `noreturn_discstrict` (on|off, default ON) keeps the terminal arm (a call with no fall-through VMA at all -- a tail jump lowered to a call, a property of the call instruction) and the two POSITIVE arms (the successor is data, so it is outside every executable range; the successor is another function's entry) and drops the bare one. `off` restores the legacy three-arm order verbatim. Dropping it also makes the data arm reachable for the first time -- `is_data` implies `!is_instruction_start`, so the legacy order consumed every site it would have caught. `strict` evidence is a subset of `legacy` evidence at every call site, so the change can only remove a no-return conclusion, never add one. No decode-outcome record was added to the Listing, deliberately: recording WHY an address has no instruction would make the arm honest but leave it a statement about the decoder, so a spec gap on Thumb/MIPS16/PPC VLE would still vote to delete a caller's code. Measured, instrumented A/B inside one process over 975 real binaries: 693 stripped x86-64 decbench binaries (aggressive) legacy 766 conclusions vs strict 766, 0 lost, and the dropped arm cast 0 votes at any call site; 110 stripped non-x86-64 (98 ARM32 + 12 i386 PE) legacy 0 vs strict 0 with 1 arm vote in the whole corpus; 168 /usr/bin ELF binaries 0 arm votes; 4 clang/LLVM-14 binaries 0. Emitted C off vs on is byte-identical over 18 binaries / 382,515 lines. Closes #312. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1
mahaloz
force-pushed
the
feat/noreturn-discstrict
branch
from
August 27, 2026 19:43
93b0f39 to
96c2d03
Compare
mahaloz
added a commit
that referenced
this pull request
Aug 27, 2026
[AUTOMATED] DIV-90/91/92 were claimed by #341/#342/#344 while this branch was in flight; the row and every reference move to DIV-93. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1
mahaloz
added a commit
that referenced
this pull request
Aug 27, 2026
…e aggressive preset (DIV-93) (#345) * feat(modes): the four ARM entry-discovery options join the aggressive preset (DIV-90) cortexmvectors (#248), ptrentry (#255), tailcallentry (#259) and poolentry (#278) all shipped default-OFF and sat on the UNEVALUATED list in modes.rs, so they were absent from AGGRESSIVE_OVERRIDES. `auto` resolves to `aggressive` under 500 KiB, and the preset is what the whole-binary surfaces actually run, so all four were INERT on every default path -- the DIV-64 itaniumrtti trap, four times over. The default path's stripped-ARM entry recall had not moved since they merged. They are flipped jointly because they compose, which is exactly what the UNEVALUATED comment demanded before any flip. Measured over the 110 stripped non-x86-64 decbench twins against their unstripped twins' symbol tables (50,724 ground-truth function starts), --mode aggressive: arm entries exact midbody recall added added_exact lost_exact base 55006 44957 8333 88.63% - - - cortexm 55142 45093 8333 88.90% 136 136 0 ptr 56594 46522 8333 91.72% 1588 1565 0 tail 55655 45602 8337 89.90% 649 645 0 pool 53956 45122 7116 88.96% 167 165 0 all4 56188 47330 7117 93.31% 2402 2373 0 Recall and precision improve together: +2,373 real entries (98.8% of everything added is a real function start) while mid-body false entries FALL 8,333 -> 7,117. No ground-truth entry is lost by any arm -- poolentry's 1,217 removals contain zero ground-truth addresses. 0 of 110 binaries lose recall. Restricted to the 105 binaries `auto` actually sends to `aggressive` (< 500 KiB), the default-path number is 90.92% -> 96.06%. The 5 images at/over the threshold resolve to `reliable` and are disclosed in the DIV row rather than papered over. Non-ARM inertness is measured: identical entry sets over 90 x86-64 twins and the 12 i386 PE images in the ARM corpus, byte-identical emitted C over 8 x86-64 binaries. Speed, interleaved min-of-4: decompile-all cf2.elf -5.8% (a speedup), nuttx +3.5%, x86-64 controls at noise; discovery-only `kuna functions` +6.2%, which is more work for more output on the one surface that only does discovery. The 0/675 ablation is proven, not asserted: a throwaway build with all four forced ON as engine defaults -- strictly stronger than preset membership, which the XML harness never applies -- still reports 675/675 and 538/538 PARITY OK. Also lands PR #239's two doc corrections, repointed at the shipped feature docs rather than at its unshipped-proposal directory: the recall-measurement.md mechanism/noise correction and the missing-ghidra-analyses.md OperandReferenceAnalyzer row (its "function creation is subsumed by entry-disc" claim is what ptrentry disproved). [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs(decbench): retire the two round-ledger claims DIV-90 falsifies features-round4.md Rank 6 was a filed, still-open recommendation to flip `tailcallentry` into the preset ("aggressive does not carry it"); DIV-90 does exactly that, so it is marked SHIPPED with the sweep it asked for. features.md still called step 3 "in flight" and did not know about step 5 (`poolentry`, #278). [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs: state the ARM restriction precisely -- poolentry has no arch gate cortexmvectors/ptrentry/tailcallentry each early-return on `object::Architecture::Arm`; poolentry does not, and is ARM-only in EFFECT because it keys on PC-relative literal pools. The measured inertness is the same either way (identical entry sets on 90 x86-64 twins and 12 i386 PE images), but "all four are ARM-gated" overstated the mechanism for one of them. [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs(history): add the leave-one-out direction to the DIV-90 evidence Dropping each option from the combination loses 27 / 1427 / 645 / 136 ground-truth entries respectively, and dropping poolentry is the only one that also raises mid-body false entries (7117 -> 8337). No option is redundant given the others. [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs: renumber the ARM-preset divergence to DIV-93 [AUTOMATED] DIV-90/91/92 were claimed by #341/#342/#344 while this branch was in flight; the row and every reference move to DIV-93. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #312.
noreturn_discconcludes a callee never returns once ≥3 of its call sites "show novalid fall-through". Three arms implemented that test, tried in order:
Arm 1 does not mean what its name says, and the issue understates it.
listing/walk.rspushes every call's fall-through onto the per-function instruction worklist
unconditionally (
walk.rs:167-170), and that worklist drains before the function is left,so a call's successor is always attempted. It fails to become an instruction start in
exactly three ways:
decode_onereturnedErr(walk.rs:129-132, the error dropped onthe floor), the decode was zero-length, or the address is outside every executable range.
The Listing keeps no decode-outcome record —
CodeUnitis onlyInstruction/Data/Undefined, andcode_unit_atderivesUndefinedfrom "in an execrange and not covered" — so a failed decode and an unvisited byte are indistinguishable.
Arm 1 is therefore precisely and only a decode-failure detector: a fact about kuna's
SLEIGH coverage, feeding a rule that removes code. And since
is_data(fall)implies!is_instruction_start(fall), arm 2 has been unreachable since the pass shipped.I verified both claims in code and by running: instrumenting the pass to compute the two
tallies side by side over 975 real binaries shows arm 1 casting one vote in all of
them (see below), and the new fixture shows it casting exactly 3 and forging a verdict.
The bug, minimal
retsevenismov $7,%eax ; ret. Three callers follow theircall retsevenwith thesingle byte
0x06(push %es, invalid in 64-bit mode). Three decode failures = threevotes = the threshold:
The change
New option
noreturn_discstrict(on|off, default ON, tiertransform, DIV-90),gating the narrowed predicate in
kuna-analysis/src/analyzers/noreturn_disc/kuna_discstrict.rs. It keeps the terminal arm(a property of the call instruction: a tail jump lowered to a call) and the two
positive arms — the successor is data (outside every executable range, so the compiler
emitted nothing to fall into), or the successor is another function's entry (the compiler
left the caller no tail) — and drops arm 1.
offrestores the legacy three-arm orderverbatim. Dropping arm 1 is also what makes arm 2 reachable for the first time.
strict ⟹ legacyat every call site, so the change can only ever remove a no-returnconclusion, never add one.
No decode-outcome record was added to the Listing, deliberately. Recording why an
address has no instruction would make arm 1 honest, but it would remain a statement about
the decoder: a SLEIGH gap on Thumb/MIPS16/PPC VLE would still vote to delete a caller's
code.
noreturn_propagate(no threshold, seeded from the Known list) already covers thepadding-tail wrapper shape the tally was reaching for.
It ships as an option rather than a bare bug fix because it narrows a default-ON,
code-removing analyzer — AGENTS.md's "when in doubt, gate it".
Measurement — this is what decided the default
Instrumented A/B inside one process (both tallies computed over the same Listing, the
fact sets diffed by address),
--mode aggressiveso the Listing is on for every surface.--mode aggressiveauto/usr/binELF binariesFileCheck-14,clang-14,llvm-nm,llvm-strings)975 real binaries, one arm-1 vote in all of them, zero conclusions changed.
How many callees depend on the weak arm alone → 0 of 766. Not "0 net": arm 1 cast
zero votes at any call site on the entire x86-64 corpus and on every system binary. The
single vote in the whole non-x86-64 corpus is on
O2-noinline/u-boot, at a callee thatneeds three.
The non-x86-64 slice is the risk the scout named, and it is inverted. kuna's decoder
gaps are widest on ARM/Thumb/MIPS/PPC — but on fixed-width RISC ISAs almost every bit
pattern decodes as something, so
decode_onerarely errors and arm 1 rarely fires.noreturn_discconcludes nothing at all on all 110 of those binaries under eithertally, so there is no genuine conclusion there to lose. No mitigation was needed.
(Instrument validated in both directions on the two fixtures: the forge shows
NRDS-WEAK ... weak_only=3, the genuine-die()fixture showssites=0and identicalconclusions.)
Emitted-C collateral —
decompile-all --json | jq -r '.functions[].code', off vs on,18 binaries, 0 changed lines out of 382,515,
// no-returncount identical in everypane:
The 12 decbench targets are the highest-conclusion-count binaries in the corpus, so this
is the sample most likely to move, not a random one. The only hunk anywhere is the new
fixture's, shown above.
/usr/bin/FileCheck-14(the [AUTOMATED] std::__throw_* family missing from the ELF no-return list: dead code after libstdc++ throw helpers #273 clang binary from the issue's provenance story):102
// no-returnannotations in both panes, 64,308 lines byte-identical, 0 arm-1 votes.The
std::__throw_*family it turns on is already covered by name post-DIV-78.Speed — interleaved min-of-8 with the arm order alternated per rep, on a box at
load 10–18 shared with several other agents:
The sign flips with arm ordering, so the number is noise-dominated and I claim none of
them. What is structural: the strict path performs strictly fewer Listing lookups per
call site, and on every binary measured the emitted C is byte-identical, so the decompile
work is unchanged. Well inside the 5% budget in the only direction that matters.
Tests
kuna-console/tests/verify_noreturn_discstrict.rs— 4 cross-crate tests over the newchecked-in fixture
noreturn_discstrict_x86_64, built reproducibly from checked-inassembly by the one-line
gcccommand in its header (nothing byte-patched):default keeps
return retseven() + 3and marks nothing no-return;offrestores theforged
// no-returnform and the truncated_start;retsevenisreturn 7underboth; and — the no-regression half — the pre-existing
noreturn_disc_x86_64fixture'sgenuine
die()wrapper is still concluded no-return under the default withnoreturn_propagateforced off, because all four of its call sites take their evidencefrom the surviving arm 3.
tests/stages/kuna-noreturn-discstrict.xml— wiring only, and that is a tier limit,not an omission: the Listing is built solely on the real-object bootstrap path, so an
off=bug/on=fix datatest is not constructible on the XML
<binaryimage>path. Same splitghangr-noreturn-error.xml+verify_noreturn_error.rsalready use. Corpus 215 → 216files,
docs/baseline-stages.jsonre-recorded (539 keys, one newly passing).Gates
Both parity gates are vacuous here and are stated as such in the DIV row: every fixture
in
tests/datatests/andtests/stages/is a symbol-less<bytechunk>and the Listing isreal-object-only, so "675/675 unchanged" is true and proves nothing about this change. The
evidence is the 975-binary A/B above plus the new fixture.
Counts bumped
kuna_phases/tests.rskuna_num_settables()/SETTABLE_TABLE.len()kuna_phases/tests.rstier counts(core, transform, analysis)kuna_phases/tests.rscatalog JSON row-comma countcatalog_bytecompat.rs"option":/"tier":/"symptoms":kuna-base/src/xml.rscorpus file counttests/fixtures/phase_catalog.jsondocs/options.mdtests/stages/kuna-catalog.xmlneeded no change: itsmin/maxassertions are onsource_decompiler: "angr"(32),change_kind: "structure-recovery"(26) andchange_kind: "opt-in-tool"(15); this row iskuna/correctness-fix, and the twouse_when/change_kindpresence assertions havemax=160.DIV number: claimed DIV-90 (highest on main is DIV-89). Siblings may claim 90..93 —
if one merges first, renumber the row in
docs/history.mdand its references inarchitecture.rs,options.rs,phases.toml,docs/options.md(regenerate),docs/spec/01-program-prep.mdandkuna_phases/tests.rs.🤖 Generated with Claude Code
https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1