Repository navigation
tee-o2-x2nrealloc: structural no-return propagation (option noreturn_propagate) - #52
Merged
Merged
Conversation
… (noreturn_propagate) angr renders tee_O2:x2nrealloc cleanly; kuna emits invalid C (spurious while(true) loop + goto + dead stack spills) because xalloc_die is no-return (body unconditionally ends in error(); abort()) but kuna never propagates that fact to xalloc_die. Confirmed: manual `option noreturn xalloc_die` collapses the output to the angr shape. The faithful fix is angr's CFGFast no-return call-graph propagation: a new analysis-tier pass seeding from the known/discovered no-return set and marking any function whose last reachable insn is a call to a no-return callee, to a fixpoint. A decider ruled scope=large: the no-return flag is consumed pre-S2-flow via an &self seam (no loweredswitch-style Action possible), and no firing tests/stages/*.xml can be authored (the XML path never runs analysis passes). Proposal only -- no implementation. See docs/features/tee-o2-x2nrealloc-6981e7/. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Jun 25, 2026
…e (PR #52) Discovered the real fix (noreturn-by-body inference for usage()) is the EXACT feature already proposed as `noreturn_propagate` (draft PR #52, from xalloc_die in tee_O2). This mv_-O2/usage case is a second witness for that feature. Per Hard rule 5 (do not duplicate a covered gap), no competing proposal is spun up; this opportunity is closed as covered. Reframed findings.md/proposal-v2.md/record.json/PROGRESS.md accordingly. No code shipped. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…return_propagate) Closes the angr gap test_decompiling_tee_O2_x2nrealloc::x2nrealloc. xalloc_die is structurally no-return (body ends unconditionally in error(); abort(), and abort is already modeled no-return) but kuna never propagates that, so the call xalloc_die in x2nrealloc is assumed to return and at -O2 the cold-path bytes after it form a spurious while(true) loop + goto + dead stack spills (invalid C, 38% longer than angr). New kuna-analysis Listing-consumer pass s1_noreturn_propagate::NoReturnPropagatePass (gate id noreturn_propagate, default-OFF, requires option listing on) — the kuna analog of angr's CFGFast call-graph no-return propagation. Seeds the terminal set from the Known no-return list and concludes a function no-return when its last real instruction (skipping trailing NOP padding) is a CALL/tail JMP to an already-no-return callee, with no RETURN path, no computed jump, and no escaping branch — iterated to a fixpoint, with NO evidence threshold (the difference from noreturn_disc, which misses xalloc_die: one cold call site, call abort followed by valid NOP padding). Emits the existing NoReturnFact -> the existing set_function_no_return commit seam (no new commit arm, no S7 work). Implements the approved docs/features/tee-o2-x2nrealloc-6981e7/proposal.md. Coverage (no stages XML — analysis tier, like noreturn_known/noreturn_disc): a vendored differential fixture noreturn_propagate_x86_64 (custom my_die() wrapper called once, ending in call abort + NOP padding) drives verify_noreturn_propagate.rs (3 assertions incl. the noreturn_disc-does-not-fix-it differential) + kuna-analysis pass-identity unit tests. Default-OFF opt-in (real-ELF-only flow heuristic, listing-gated): ablation 0/675, make test PARITY OK, no DIV entry. Speed x2nrealloc off=154.6ms/on=151.1ms (-2.21%, within budget). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mahaloz
marked this pull request as ready for review
June 25, 2026 05:43
…nion + ordering) The before/after demo for an analysis-tier option must (a) emit `option` lines BEFORE `read symbols` — the kuna_analysis passes commit inside read symbols, so an option set after it is too late (the Rust `kuna decompile` CLI already does this; the python shim scripts/decompile.py did the opposite, a latent bug); and (b) apply a companion flag the feature requires (`listing on`) to BOTH sides so the demo isolates the feature option's own effect. - scripts/decompile.py: move `option` emission before `read symbols` (match kuna-cli/src/decompile.rs). No-option decompiles are byte-identical. - scripts/pipeline/prdemo.py: add `demo_extra_options` (applied to before+after). - record.json: demo_extra_options = [["listing","on"]]. With this, the embedded demo shows the real fix: gotos 1->0, labels 1->0, loc 39->27. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Author
|
Great work, this is ready to merge after documenting for another agent:
|
Bring the noreturn_propagate (structural no-return propagation) feature branch up to current main. noreturn_propagate is opt-in (default-off, no DIV entry). Conflicts resolved by UNION: - stages.toml: 42 settable blocks; count assertions updated to 42 - stage_catalog.json fixture: union noreturn_propagate + gopclntab + relocobjects rows - kuna-catalog.xml / baseline: angr provenance 8 (noreturn_propagate added), structure-recovery 4 (noreturn_propagate is structure-recovery) - PROGRESS.md: noreturn_propagate session kept ahead of the main sessions - assertions.md + baseline-stages.json regenerated Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (163/163). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
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.
noreturn_propagate: structural no-return propagation (angr CFGFast analog)Closes the angr gap
test_decompiling_tee_O2_x2nrealloc::x2nrealloc(coreutilstee_O2, x86_64). Implements the approvedproposal; analysis in
analysis.md.
The gap
angr renders
x2nrealloccleanly; kuna emits invalid C — a spuriouswhile(true)loop +goto label_5813+ dead stack-spill artifacts, 38% longer(39 vs 24 loc). Root cause:
xalloc_dieis structurally no-return (its bodyunconditionally ends in
error(...)thenabort(), and kuna already modelsabortno-return), but kuna never propagates that toxalloc_die— so thecall xalloc_dieinx2nreallocis assumed to return, and at-O2(cold errorpath laid out last) the bytes after the call become a spurious fall-through
back-edge. Marking
xalloc_dieno-return by hand (option noreturn xalloc_die)collapses the output to the angr shape, confirming the mechanism is exactly
no-return propagation.
The mechanism
A new
kuna-analysisListing-consumer pass(
s1_noreturn_propagate::NoReturnPropagatePass, the kuna analog of angr's CFGFastcall-graph no-return propagation). It seeds the terminal set from the Known
no-return list and concludes a function no-return when its last real
instruction (last by address, skipping trailing NOP alignment padding) is a
CALL/tailJMPto an already-no-return callee, with noRETURNpath, nocomputed jump, and no branch escaping the reachable body — iterated to a
fixpoint, with no evidence threshold. This is the key difference from the
existing
noreturn_disc, whose ≥3-call-site rule and "valid fall-through after thecall" predicate both miss
xalloc_die(one cold call site;call abortfollowedby valid NOP padding).
It emits the existing
NoReturnFact→ the existingset_function_no_returncommitseam → the inherited
flow.rsartificial-halt path. No new commit arm, no S7work. Soundness: with no
RETURNand the only reachable exit a call/jump to analready-no-return function, the function cannot return — strictly more conservative
than angr's propagation.
The option (LLM-discoverable)
option noreturn_propagate on— default-OFF opt-in, requiresoption listing on(it reads the Listing/xref tier). Provenance instages.toml:source_decompiler="angr",change_kind="structure-recovery",inspiration="test_decompiling_tee_O2_x2nrealloc; angr CFGFast no-return propagation …; x2nrealloc".Why a proposal (large), and testing
The no-return flag is consumed pre-pipeline during initial flow generation
(
s2_lift/flow.rs:1838,&self), so akuna_loweredswitch.rs-style in-pipelineAction runs too late — this must be an analysis-tier pass. And the mandated firing
tests/stages/*.xmlcannot be authored: the XMLdecomp_test_dbgbytechunk pathnever runs analysis passes or builds the Listing (exactly why
noreturn_known/noreturn_dischave no stages XML test). Coverage instead:verify_noreturn_propagate.rsover a vendored differentialfixture (
noreturn_propagate_x86_64: a custommy_die()no-return wrapper calledONCE — below
noreturn_disc's ≥3 threshold — ending incall abort+ NOPpadding). Three assertions: propagation eliminates the dead code; the existing
noreturn_discconsumer does not fix it (the differential proving a newcapability); the wrapper itself is concluded no-return.
kuna-analysispass-identity unit tests.Ablation / parity / speed
make teststays PARITY OK. Kept default-OFF (real-ELF-only flow heuristic) —no DIV entry, default output byte-identical.
make test-stagesPARITY OK (the twoKUNA-CATALOGprovenance-countassertions re-pinned for the new angr/structure-recovery row; baseline
regenerated).
make rust-testgreen except the pre-existingverify_w10_proto_unlockfailure (reproduces on the unmodified branch; unrelated to this change).
x2nrealloc, repeat 5): off=154.6 ms / on=151.1 ms (−2.21%, withinthe 5% budget). The pass is one bounded call-graph fixpoint over an
already-built Listing.
🤖 Generated with Claude Code
Before / after —
x2nreallocintee_O2Real captured kuna output on the function this feature was built for, with
option noreturn_propagateflipped. Ported from angr — test_decompiling_tee_O2_x2nrealloc; angr CFGFast no-return propagation (returning / _iteratively_analyze_function_features); x2nrealloc.noreturn_propagate off(default)noreturn_propagate onkuna — before (
option noreturn_propagate off)kuna — after (
option noreturn_propagate on)angr reference (the goal, v9.2.213)