Repository navigation
Listing/xref tier PR6: discovered-no-return consumer (the payoff) - #29
Merged
Merged
Conversation
The first analyzer built on the Listing/xref model — the kuna analog of Ghidra's
FindNoReturnFunctionsAnalyzer ("Non-Returning Functions — Discovered"). It finds
CUSTOM no-return wrappers the static name-lists cannot catch (a local die() that
tail-calls exit) by flow evidence over the program-wide Listing, and marks them
no-return through the EXISTING NoReturnFact commit seam. Two parts:
PART A — the build-timing fix. PR2 flagged it: the live CLI emits `option listing
on` AFTER `load file`, but the analysis driver runs at load, so a Listing gated on
arch.analysis_listing never builds through the CLI. Following the Increment-13
deferred-commit precedent, bootstrap_from_elf now stashes the image bytes+path on
ConsoleProgram (analysis_image), and the Listing build + Listing-consumer run is
DEFERRED into commit_pending_analysis (reached at `read symbols`, after the option
lines). Gated on arch.analysis_listing (now in effect), the stashed bytes are
re-parsed, the Listing built (funcsym names + Known-no-return seed metadata via
Listing::with_noreturn_seeds), passes::run_listing_consumers runs the consumer,
and its per-pass-gated facts merge into the same AnalysisOutput the deferred commit
already commits — through the UNCHANGED no-return commit arm. Default (listing off)
⇒ the whole block is skipped ⇒ byte-identical to today; XML path stashes no image
⇒ structural no-op.
PART B — the consumer (s1_noreturn_disc, id noreturn_disc, default-OFF, its own
flag + full wiring). run short-circuits to empty when ctx.listing is None. The
evidence-tally fixpoint over the Listing: (1) a callee is no-return when ≥3 of its
call sites show no valid fall-through (byte after `call` is not an instruction
start / is data / is another function's entry); (2) fixpoint promotion — a function
whose every terminal path is a call to an already-discovered-no-return function,
with no returning path, is itself no-return. Skips callees already modeled
no-return / call-fixup'd. Emits NoReturnFact (no new commit arm); flow-repair is
inherited from the engine.
END-TO-END (real, not faked). Fixture noreturn_disc_x86_64 (+.c), gcc -O1 -no-pie:
a static die() that fprintf+exit(1), NOT noreturn-marked, called from 4 functions;
at -O1 gcc emits nothing after each `call die` (the next byte is the next
function's entry). compute_a:
BEFORE (default): die treated as returning ⇒ the decompiler falls through past
`call die` through compute_b/c/d into main (massive merged dead code).
AFTER (--option listing on --option noreturn_disc on): die concluded no-return ⇒
`int4 compute_a(int4 a0) { if (0 <= a0) return a0 * 2;
/* WARNING: Subroutine does not return */ die("a: negative"); }`
Gating invariants verified: noreturn_disc-on+listing-off and listing-on+
noreturn_disc-off both equal the default; only BOTH flags change output.
settable_count 35 → 36 (the noreturn_disc gate); stages.toml row + header,
KUNA_OPTION_NAMES, architecture.rs field/default/reset/set_kuna_option,
engine.rs analysis_pass_enabled arm, the count-fixture ripple (kuna_stages tests,
catalog_bytecompat, stage_catalog.json), docs/assertions.md regenerated.
Gates: make test 675/675 PARITY OK; make test-stages 159/159 PARITY OK;
make rust-test green; kuna catalog --check OK. New e2e verify_noreturn_disc.rs
(3/3, ran not skipped).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
…-disc # Conflicts: # docs/analysis-port-log.md
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 14, 2026
…t, a wide reload or ECX, and from reusing walks across the option Three lost-read shapes the stack-address tracking still missed each dropped a real argument: a local's address stored over the callee's own argument slot and loaded back, a slot holding one copied by an 8-byte move, and a stack address a nested call leaves in ECX. A store of a stack address to a stack location whose slot is not followed now leaves the extent unstated, a load is lost when it overlaps any followed slot, and every caller-saved register a returning callee leaves a stack address in is lost. The walk summaries are cached on the architecture, and the tracking only runs with calleeargs on, so turning the option on in a session that had walked a callee with it off reused the untracked walk and dropped the arguments again. The cache now drops its walks when the option changes. Stage cases CALLEEARGS Noelo-Lab#26-Noelo-Lab#29 (calleelost_pe_i386 extended, recipe in its header) fail on the previous head and pass now; the 62-binary i386 corpus is byte-identical to the previous head. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 14, 2026
…load Comparing values lets `mov ecx,esi; mov eax,[esi]; call [eax+k]` pass the object in ECX, since ECX holds it at the call; the vcall fixture gains ecxcopy for it (stage Noelo-Lab#28, Noelo-Lab#29, the custom test) and spec 04 says so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
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.
The first analyzer built on the Listing/xref model — the kuna analog of Ghidra's
FindNoReturnFunctionsAnalyzer("Non-Returning Functions — Discovered"). It finds custom no-return wrappers the static name-lists cannot catch (a localdie()that tail-callsexit) by flow evidence over the program-wide Listing, and marks them no-return through the existingNoReturnFactcommit seam. Default-OFF.PART A — the build-timing fix (the mechanism)
PR2 flagged it: the live CLI emits
option listing onafterload file, but the analysis driver (run_default_analyses_per_pass) runs at load, so a Listing gated onarch.analysis_listingnever builds through the CLI (the flag is still default-off at load).The fix mirrors the Increment 13 deferred-commit precedent. At load,
bootstrap_from_elfnow stashes the image bytes + path onConsoleProgram(analysis_image); the build of the Listing — and the run of any Listing-consumer pass — is deferred tocommit_pending_analysis(reached atread symbols, AFTER the CLI'soptionlines). There, gated onarch.analysis_listing(now in effect), the stashed bytes are re-parsed, the Listing is built (funcsym names + Known-no-return seed metadata viaListing::with_noreturn_seeds), the newpasses::run_listing_consumersruns the consumer over it, and its (per-pass gated) facts merge into the sameAnalysisOutputthe deferred commit already commits — through the unchangedcommit_analysis_outputno-return arm (find_function_across_scopes/query_global_function→set_function_no_return). Flow-repair / dead-code elimination is inherited from the engine. Default (listing off) ⇒ the whole deferred block is skipped ⇒ byte-identical to today; the XML path stashes no image ⇒ structural no-op.PART B — the consumer (
s1_noreturn_disc, idnoreturn_disc, default-OFF)A new gated
AnalysisPasswhoserunshort-circuits to empty whenctx.listing.is_none(). The evidence-tally fixpoint over the Listing:refs_to(callee)Call edges) show no valid fall-through — the byte aftercallis not a decoded instruction start (!is_instruction_start), or is data (is_data), or is another function's entry (function_at(fall)), or the call has no fall-through at all. (Ghidra's evidence threshold = 3.)function_at(t).has_no_return, seeded from the Known pass) or call-fixup'd. EmitsNoReturnFact { addr, name }— no new commit arm.The END-TO-END before/after (real, not faked)
Fixture
noreturn_disc_x86_64(+.c),gcc -O1 -no-pie -fno-pic: astatic void die(const char*)thatfprintfs thenexit(1), not__attribute__((noreturn)), called from four functions (compute_a/b/c/d). At-O1gcc emits nothing after eachcall die— the byte after the call is the next function's entry — so all four call sites show no-valid-fall-through (≥3).compute_a, BEFORE (default, flags off) —dieis treated as returning, so the decompiler follows the fall-through pastcall diethroughcompute_b/compute_c/compute_dintomain(massive merged dead code):compute_a, AFTER (--option listing on --option noreturn_disc on) —dieis concluded no-return; the engine's inherited repair eliminates the dead code:Gating invariants (the parity proof). Verified directly:
noreturn_disc on+listing off⇒ identical to default (no Listing to read);listing on+noreturn_disc off⇒ identical to default (Listing built, consumer gated off). Only both flags on changes output ⇒ the default path is byte-identical to today.Wiring
settable_count35 → 36 (thenoreturn_discgate):stages.tomlrow + header count,KUNA_OPTION_NAMES,architecture.rsfield/default/reset/set_kuna_option,engine.rsanalysis_pass_enabledarm, the count-fixture ripple (kuna_stagessettable_count_is_36/…suppressed_for_14/…brackets_and_commas/catalog_bytecompat/stage_catalog.json),docs/assertions.mdregenerated.Gates
make test— 675/675 PARITY OKmake test-stages— 159/159 PARITY OKmake rust-test— greenkuna catalog --check— catalog OKverify_noreturn_disc.rs— 3/3, ran (not skipped)Do not merge.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb