Repository navigation
tail-tail-bytes-ret-dup-f79d1d: name-based no-return for undefined externs (option noreturn_extern) - #90
Merged
Conversation
…(opt-in) Closes the angr `test_tail_tail_bytes_ret_dup` gap on `tail.o::tail_bytes` (an ELF relocatable object). kuna decompiled the 615-byte function as 326 lines / 9 gotos, running far past its end and swallowing adjacent functions after the canary epilogue's `__stack_chk_fail()`; angr renders 96 lines / 1 goto. Root cause: in a `.o`, `__stack_chk_fail` is an UNDEFINED external symbol (UND, NOTYPE, size 0). The analysis-tier `noreturn_known` pass keys on the ADDRESS of a *defined* FUNC symbol, so it never marks the UND extern; at flow time `query_call_no_return` returns false, no artificial halt is planted, and flow runs off the function's end. Fix: a name-based fallback in the flow seam `ArchFlowEnv::query_call_no_return` (infra/decompile_drive.rs): when the address-keyed check is false and the gate is on, name-match the resolved callee against the known ELF no-return list (kuna_noreturnextern::matches_noreturn_extern_name, mirroring the analysis-tier name_matches). New module kuna_noreturnextern.rs (ElementId 4103), Architecture flag noreturn_extern_calls modelled on tail_call_jumps. No new pass type, no S7. `option noreturn_extern on` -> tail_bytes 326 -> 87 lines (37% faster). Kept DEFAULT-OFF opt-in: the name match overlaps noreturn_known's for defined/imported symbols, so default-on would change PE/ELF exit-family handling under `noreturn_known off` (verify_multiformat_passes::pe_exit...). 675-datatest ablation with the gate on is 0/675. Test tests/stages/ghangr-noreturn_extern.xml (+2, baseline-stages 190 -> 192). Gates: make test PARITY OK 675/675, make test-stages 192/192, catalog --check OK, make rust-test green except the pre-existing verify_w10_proto_unlock oracle drift (unrelated, fails on branch HEAD). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Author
|
I approve this, but you should also note to future agents and start them up on fixing the following based on this case:
|
Union-resolve the shared registration/count files so noreturn_extern (ElementId 4103, default-off opt-in) coexists with main's advancement: - stages.toml header settable=54->55 (32 stage-model knobs); +1 settable block - kuna_stages/tests.rs: settable count 55, json-comma 54, live-value 24; test fns renamed settable_count_is_55 / live_value_present_for_24_suppressed_for_31 - catalog_bytecompat.rs: fixture_has_all_55_settables (32 stage + 20 analysis + 3 loader) - kuna-base/xml.rs corpus count 146 (83 datatests + 63 stage tests) - kuna-catalog.xml: source_decompiler angr count 15 (adds noreturn_extern) - regenerated docs/assertions.md + docs/baseline-stages.json (205 keys) Gates green: kuna catalog --check OK; make test 675/675 PARITY OK; make test-stages 205/205 PARITY OK. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
mahaloz
added a commit
that referenced
this pull request
Jun 26, 2026
) Union-resolve so noreturn_externmatch coexists with #90's noreturn_extern (both name-match the ELF no-return list at the same flow seam). Deconflicted: - ElementId 4103 -> 4104 (4103 taken by #90's noreturn_extern on main) - DIV-12 -> DIV-13 (DIV-12 taken by main's region structurer); renumbered in divergences.md, architecture.rs, stages.toml, the module, the testcase XML, UPSTREAM.md, stage-mapping.md, PROGRESS.md, feature record/plan/pr_body - decompile_drive.rs query_call_no_return: BOTH gated checks kept (noreturn_extern_match + noreturn_extern_calls) - s2_lift/mod.rs: both modules declared - stages.toml header surface=95, settable=56 (33 stage-model knobs); +1 surface +1 settable - kuna_stages/tests.rs: settable 56, surface 95, json-comma 55, live-value 25; test fns renamed (settable_count_is_56 / live_value_present_for_25_suppressed_for_31) - catalog_bytecompat.rs: fixture_has_all_56_settables - kuna-base/xml.rs corpus count 147 (83 datatests + 64 stage tests) - kuna-catalog.xml: source_decompiler angr count 16 (both noreturn_extern + externmatch) - #90's ghangr-noreturn_extern.xml: pass 1 now also sets `noreturn_externmatch off` to isolate the noreturn_extern toggle (externmatch default-on else bounds it first) - regenerated stage_catalog.json fixture, docs/assertions.md, baseline-stages.json (208 keys) Gates green: kuna catalog --check OK; make test 675/675 PARITY OK; make test-stages 208/208 PARITY OK. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
mahaloz
added a commit
that referenced
this pull request
Jun 26, 2026
Union-resolve so crossjumprevert (opt-in default-off) coexists with #90's noreturn_extern and #91's noreturn_externmatch on main. Deconflicted: - ElementId 4103 -> 4105 (4103=noreturn_extern, 4104=noreturn_externmatch on main) - stages.toml header surface=95, settable=57 (34 stage-model knobs); +1 settable - kuna_stages/tests.rs: settable 57, surface 95, json-comma 56, live-value 25 (crossjumprevert has no live reader, in the suppressed allowlist); test fns renamed (settable_count_is_57 / live_value_present_for_25_suppressed_for_32) - catalog_bytecompat.rs: fixture_has_all_57_settables - kuna-base/xml.rs corpus count 148 (83 datatests + 65 stage tests) - kuna-catalog.xml: source_decompiler angr 17, change_kind structure-recovery 9 (both add crossjumprevert) - verify_w8_fw_universalaction.rs auto-merged: 262 leaves (252 C++ + branchflip + gotoreduce + crossjumprevert + 7 headers); universalaction/seams/architecture/block wiring of revert_cross_jumps preserved alongside the noreturn_extern* additions - regenerated stage_catalog.json fixture, docs/assertions.md, baseline-stages.json (212 keys) Gates green: kuna catalog --check OK; make test 675/675 PARITY OK; make test-stages 212/212 PARITY OK. 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_extern: bound functions at undefined-extern no-return calls (opt-in)
Closes the gap angr's
test_tail_tail_bytes_ret_dupexposes ontail.o::tail_bytes(an ELF relocatable object). Full write-up:
docs/features/tail-tail-bytes-ret-dup-f79d1d/analysis.md.The gap
kuna decompiled
tail_bytes(a 615-byte function,0x401e80..0x4020e7) as 326 lines /9 gotos, running far past the function's real end and swallowing several adjacent
functions (
tail_lines, afstatfs/die_pipefunction, anlstatloop, …), evensynthesizing a bogus
do { … } while (…)outer loop. angr renders 96 lines / 1 goto.Root cause
In a
.o,__stack_chk_failis an undefined external symbol (UND,NOTYPE, size 0).kuna's analysis-tier known-no-return pass (
noreturn_known, default on) keys its facts onthe address of a defined
FUNCsymbol, so it never marks the UND extern — even thoughits base name is on the shipped ELF no-return list. At decompile flow time the call resolves
to a display name but the symbol's no-return flag is false, so
FlowEnvironment::query_call_no_returnreturns false, noartificialHalt(noreturn)isplanted, and flow runs off the function's end into the next function.
Mechanism
A name-based fallback in the flow seam
ArchFlowEnv::query_call_no_return(
infra/decompile_drive.rs): when the address-keyed check is false and the gate is on,resolve the callee display name and return true if
matches_noreturn_extern_namematches theknown ELF no-return list (leading-
_strip +std-only namespace guard, exact match againsta closed set — mirrors the analysis-tier
name_matches). This plants the existing artificialhalt, so flow stops at the call and the function is bounded correctly. New module
kuna_noreturnextern.rs(ElementId 4103), Architecture flagnoreturn_extern_callsmodelledon the
tail_call_jumpsflow-seam gate. No new pass type, no S7 change.Option
option noreturn_extern on|off(S2 flow-classification, default-off opt-in).kuna decompile tail.o tail_bytes --option noreturn_extern on→ 326 → 87 lines.Why opt-in (not default-on)
The 675-datatest ablation with the gate on is byte-identical (0/675) and the target is
37% faster with it — which first argued for default-on. But
make rust-testcaught areal interaction the bytechunk-only corpus can't exercise:
verify_multiformat_passes::pe_exit_eliminates_dead_code_via_noreturn_listasserts thatoption noreturn_known offrestores the dead fall-through after a PEexit, yet thename-based fallback independently catches
exit, so default-on would silently changePE/ELF
exit-family handling undernoreturn_known off. The name match overlapsnoreturn_known's for defined/imported symbols, so the honest call is opt-in (no DIV) —like
tailcalljump/gotoreduce/stackguard. The fallback only fires when the address-keyedcheck already returned false, so it never double-fires on an already-marked callee.
Parity & speed
decodes less code.
make testPARITY OK 675/675,make test-stages192/192,kuna catalog --checkOK,make rust-testgreen (4 new unit tests).tests/stages/ghangr-noreturn_extern.xml(two-pass: pass 1offreproduces the bug,pass 2
onproves the fix);docs/baseline-stages.json190 → 192. No DIV (default outputunchanged).
🤖 Generated with Claude Code
Before / after —
tail_bytesintail.oReal captured kuna output on the function this feature was built for, with
option noreturn_externflipped. Ported from angr — test_tail_tail_bytes_ret_dup; angr CFG call-graph no-return analysis (undefined-extern __stack_chk_fail); tail_bytes.noreturn_extern off(default)noreturn_extern onkuna — before (
option noreturn_extern off)kuna — after (
option noreturn_extern on)angr reference (the goal, v9.2.213)