Repository navigation
[AUTOMATED] feat(p2): funcboundflow - bound fall-through at a known function entry, so a function ending in an unproven no-return call stops instead of absorbing the next function (DIV-67) - #280
Merged
Conversation
…unction entry (DIV-67) A kuna FunctionSymbol is an entry address with no extent, and CALL/CALLIND are fall-through, so the S2 flow follower stops only at a RETURN or a callee it can prove no-return. A function whose last act is a `call` to a no-return routine kuna cannot prove no-return -- in a stripped, statically-linked binary the unnamed exit/abort/__stack_chk_fail bodies and the app-level die()/throw wrappers built on them -- compiles with no trailing `ret`, only inter-function alignment padding, and kuna runs that fall-through straight into the NEXT function's entry, decoding its body into the current one (the following function is emitted twice: once correctly, once as a garbage tail of its predecessor). Found by an IDA-vs-kuna study of two static-pie stripped Bee-language runtimes: 70/195 (36%) application functions end in exactly such a call and are corrupted this way; e.g. numeric_item_to_i64 @ 0xa070 (FDE 0xa070..0xa0a8, last op `call bee_error_throw` -> exit) swallowed require_numeric_pair @ 0xa0b0 and print_value_lines @ 0xa100. IDA and Ghidra both bound decompilation to the function body. Fix: p2_lift/kuna_funcboundflow.rs (kuna_should_bound_at_entry) + a truncation at the fall-through push of flow.rs (FlowInfo::process_instruction). When the fall-through target is the entry of another known function (query_call(next)) and is not the current function's own entry, plant a no-return artificial RETURN (mirroring check_for_flow_modification) and emit a funcboundflow warning instead of decoding the target. `option funcboundflow` (default on); the gate is fast-pathed so default-off does zero per-instruction symbol lookups. It overlaps noreturn_extern/ noreturn_externmatch (name-based) but is name-independent, so it fixes the stripped-static case those cannot name. Evidence: 675/675 datatest PARITY OK with no re-pin (per-test opt-out on longdouble and ghangr-noreturn_extern, which deliberately exercise flow-into-an-adjacent- function); stage corpus 407/407 with a new two-pass tests/stages/funcboundflow.xml; make rust-test green (three overlapping-mechanism control tests updated to also disable funcboundflow, plus the count/tier/fixture bumps); catalog counters all 96; make check-spec OK. Speed neutral-to-positive: the bound only removes decoded instructions -- merge-heavy targets are faster, normal targets within noise. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
…funcboundflow rebase Rebased onto 11f40f4 (funcboundflow, #280, DIV-67), which registered a kuna option of its own. Both sides of the rebase had made the SAME textual 95 -> 96 edit at four counter sites, so git auto-merged them silently to 96 with no conflict shown -- the correct post-rebase value is 97. Every shared counter was re-derived from a live catalog on a green build rather than carried over: settables 96 -> 97 (counted from `kuna catalog --json`) tier split (20 core, 42 transform, 35 analysis) bytecompat fixture 96 -> 97 (recaptured via the decomp_dbg recipe; byte-identical to the merge result) catalog trailing commas 95 -> 96 xml.rs corpus count 194 (funcboundflow's; poolentry adds no XML) docs/options.md regenerated, identical to the merge result docs/baseline-stages.json unchanged (407/407 PARITY OK against main's) Feature re-verified on the rebased tree rather than assumed: funcboundflow changes function boundaries, so the entry-set it produces was compared on and off across four arms on three Cortex-M images -- IDENTICAL in every arm, and betaflight O0 reproduces the recorded per-image delta exactly (+15 / -786). No measured figure moved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH
This was referenced Aug 11, 2026
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
…funcboundflow rebase Rebased onto 11f40f4 (funcboundflow, #280, DIV-67), which registered a kuna option of its own. Both sides of the rebase had made the SAME textual 95 -> 96 edit at four counter sites, so git auto-merged them silently to 96 with no conflict shown -- the correct post-rebase value is 97. Every shared counter was re-derived from a live catalog on a green build rather than carried over: settables 96 -> 97 (counted from `kuna catalog --json`) tier split (20 core, 42 transform, 35 analysis) bytecompat fixture 96 -> 97 (recaptured via the decomp_dbg recipe; byte-identical to the merge result) catalog trailing commas 95 -> 96 xml.rs corpus count 194 (funcboundflow's; poolentry adds no XML) docs/options.md regenerated, identical to the merge result docs/baseline-stages.json unchanged (407/407 PARITY OK against main's) Feature re-verified on the rebased tree rather than assumed: funcboundflow changes function boundaries, so the entry-set it produces was compared on and off across four arms on three Cortex-M images -- IDENTICAL in every arm, and betaflight O0 reproduces the recorded per-image delta exactly (+15 / -786). No measured figure moved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
… (98.4% GT, 4,220 phantom entries retired) (#278) * [AUTOMATED] measure(armentry): poolentry - reference-driven literal-pool inference, measured against the #239 bar Refutation scaffolding for the "AIF literal-pool phantom entry" diagnosis, NOT a shippable option. Everything is behind env gates and default-inert: with no KUNA_POOL* variable set the entry sets are byte-identical to HEAD (verified on betaflight O0) and `make test` is PARITY OK 675/675. kuna_poolentry.rs pools = maximal stride-4 runs of word-aligned literal targets, harvested from the Listing AND from the speculatively-decoded bodies of the gap-discovered routines (without the latter the scan cannot see the very pools that produce the phantom). KUNA_POOLENTRY additive half: an entry fact at each pool end. KUNA_POOLSUPPRESS subtractive half: drop an AIF accept inside a pool. KUNA_POOL_MERGE_GAP bridge N unreferenced words inside a run (default 0). KUNA_POOL_AFTER_RET pool must abut a return-class terminal (additive half). KUNA_POOL_PAIRED suppress only where the pool end has a replacement entry. KUNA_POOL_TRACE dump pools / adds / suppressions. Measured over 98 ARM images (48,553 DWARF entries), baseline = --mode aggressive + cortexmvectors/ptrentry/tailcallentry: the additive half never loses an entry (0 in every configuration) but splits a real body at every operating point (104 -> 60 -> 19 -> 8, never 0), and the subtractive half removes 0 ground-truth entries yet makes 531 real function bodies unreachable unless it is paired to a replacement entry with no gap bridging, which takes that to 0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH * [AUTOMATED] measure(armentry): poolentry - complete the literal-reference set ([pc,#imm] + 64-bit two-word literals) The reference-driven pool scan only read the resolved `[0x..]` display form, which the ARM SLEIGH prints for `ldr rN,[pc,#imm]` but NOT for `vldr`/`ldrd` (ARMneon.sinc `vldrRn` resolves the target in the semantic body). Float/64-bit literal words were therefore invisible, every pool holding one under-ran, and the additive half planted an entry ON a pool word. Completing the set takes the additive arm from 19 splits (no bridging) / 8 (1-word bridging) to 1, at 98.4% ground truth, with bridging OFF - and bridging is what destroyed 62 reachable bodies in the suppression half. Measurement shim only: the Thumb/A32 PC bias is derived from the presence of 16-bit instructions. Production must read the TMode context the entry tier paints. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH * [AUTOMATED] feat(p1): poolentry - the ARM literal pool AIF never sees (98.4% GT, 4,220 phantom entries retired) Step 5 of the ARM entry-recall sequence ([PROPOSAL] #239), and the first one that is a PRECISION fix with a recall side-effect rather than the reverse. `run_aif` slides its gap cursor one byte at a time with no instruction-alignment filter, because `first_undefined_after` is byte-granular by construction. An ARM PC-relative literal pool is data, hence an undefined gap, so the cursor probes every byte of it. On STM32 Thumb the pool words are SRAM addresses 0x2000_xxxx whose HIGH halfword decodes as `movs r0,#0`, which clears the 2-mnemonic fingerprint gate as reliably as a real prologue; AIF plants an entry one halfword before the real function and then jumps the cursor past the body, so the true entry is never probed. In A32 the whole word decodes and the phantom lands on the word itself. Upstream Ghidra does not have this: its reference analyzer defines pc-relative literal targets as DATA before AIF runs. The pass reconstructs the missing definition from the references that are already there - every resolved [0x...] operand and every [pc,#imm] literal load, including the second word of a 64-bit vldr/ldrd - and takes maximal runs of ADJACENT referenced words as the pools. Completing the [pc,#imm] half is what made this shippable: without it every pool holding a float or a 64-bit constant under-runs and the additive half plants its entry ON a pool word, which is the difference between 19 splits at 89.7% ground truth and 1 at 98.4%. The PC bias is read from the engine's ContextDatabase - the same TMode the bytes were decoded under - so a language with no TMode disables the [pc,#imm] form outright. Two consumers, one option. RECALL: an additive entry fact at the end of a pool that abuts a return-class terminal, so never-removes-an-entry is a property of the wiring as in ptrentry and tailcallentry. PRECISION: drop an AIF accept inside an inferred pool, but ONLY when the pool end carries a replacement entry - unpaired that predicate removes 0 ground-truth entries and still destroys 531 real bodies, paired it destroys zero. The pairing makes the removal a MOVE. Measured on 98 stripped ARM images (48,553 DWARF addresses), baseline = steps 1-3 all on = 59,406 entries: 191 new entries, 188 ground truth (98.4%) - the best precision in the sequence 0 ground-truth entries lost, 1 real body split (disclosed) 4,220 phantom entries retired, 0 of them ground truth, 4,218 strictly inside a body 0 real bodies made unreachable, +17 newly reachable Cortex-M recall 97.25% -> 97.43%; u-boot A32 58.35% -> 60.65% (the first thing in the sequence to move an A32 image at all, at 100% precision and 0 splits) share of reported functions that are real DWARF entries 76.4% -> 82.3% Off-target: 20 x86-64 ELFs (8,171 entries) and 8 i386 PE images (1,405 entries) are byte-identical - 0 added, 0 removed. 199/199 sampled betaflight bodies byte-identical. Disclosed: one split, betaflight O2-noinline 0x8069c20, four bytes into SCSI_RequestSense - a literal reference resolves onto the function's own first word, which the Listing never decoded. The only guard that removes it costs 108 of 189 recovered entries. Pinned as current behaviour by a fixture shape. The one other non-ground-truth entry is crazyflie 0x8006a30, zero padding in no DWARF body. Analysis-tier speed is +14.3% (betaflight O0 Thumb) and +32.4% (u-boot O2 A32), over the budget and net-positive only because the retired phantoms stop being decompiled (whole-binary decompile-all on betaflight O0: 262.8 -> 220.7 s, single shot). Default-OFF, so no DIV row. Parked in modes.rs UNEVALUATED next to its three sequence siblings, which compose with it: every number above is measured on top of the other three, so preset membership is one joint evaluation rather than four. No tests/stages XML is possible - the harness never builds a Listing - so the gate is the cross-crate two-pass kuna-console/tests/verify_poolentry.rs over a new committed fixture carrying all three shapes (phantom that MOVES, unpaired phantom that is KEPT, and the disclosed split), plus an `aif off` inertness pin. Counts derived from a fresh `phase catalog` capture on a green build: settables 95 -> 96, analysis tier 34 -> 35, catalog JSON rows 95 -> 96, bytecompat fixture 95 -> 96, the catalog-form comma count 94 -> 95, and PASS_GATES gains poolentry. Gates: make test PARITY OK 675/675, make test-stages PARITY OK 405/405, make rust-test green, make check-spec green in strict mode, kuna catalog --check OK. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH * [AUTOMATED] docs(poolentry): record the shipping-build speed re-run and the final gate numbers The analysis-tier speed table now carries both runs - the env-gated measurement build and a re-run on the shipping build - with the contention disclosed. Only the A32 row (+33%) reproduces cleanly; the Thumb and x86-64 rows are inside this box's current noise floor (two other agents' workspace suites were running throughout), so the betaflight figure is stated as a range rather than a point estimate. Also records the two hard-coded count sites beyond the planned list that a green run surfaced, and the production-vs-measurement delta (removals 4,238 -> 4,220). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH * [AUTOMATED] docs(poolentry): re-derive the shared counters after the funcboundflow rebase Rebased onto 11f40f4 (funcboundflow, #280, DIV-67), which registered a kuna option of its own. Both sides of the rebase had made the SAME textual 95 -> 96 edit at four counter sites, so git auto-merged them silently to 96 with no conflict shown -- the correct post-rebase value is 97. Every shared counter was re-derived from a live catalog on a green build rather than carried over: settables 96 -> 97 (counted from `kuna catalog --json`) tier split (20 core, 42 transform, 35 analysis) bytecompat fixture 96 -> 97 (recaptured via the decomp_dbg recipe; byte-identical to the merge result) catalog trailing commas 95 -> 96 xml.rs corpus count 194 (funcboundflow's; poolentry adds no XML) docs/options.md regenerated, identical to the merge result docs/baseline-stages.json unchanged (407/407 PARITY OK against main's) Feature re-verified on the rebased tree rather than assumed: funcboundflow changes function boundaries, so the entry-set it produces was compared on and off across four arms on three Cortex-M images -- IDENTICAL in every arm, and betaflight O0 reproduces the recorded per-image delta exactly (+15 / -786). No measured figure moved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
…chain of a short-circuit (DIV-69) DIV-54 flipped `returndup` on evidence from two of the three optimisation levels. Extended to all three (795 slices / 85,195 scored functions) the pass is +640 GED-perfect corpus-wide but -192 at -O0, and one sub-shape carries essentially all of that harm and almost none of the optimized benefit: the split that permanently blocks `CollapseStructure::rule_block_or`. `returndup` gives every predecessor of a shared bare-epilogue RETURN its own private return. For a guard clause that recovers the source; but the operand blocks of a short-circuit expression are predecessors of that same block, and the shared out-target IS ruleBlockOr's entire precondition. ActionReturnDup runs in fullloop's `returnsplit` group and collapse_conditions runs later, so the fold is lost for good and one source `return a || (b && (c || d));` prints as a five-return constant-guard cascade (iproute2 ip::sci_complete, GED 21 against 0). New option `orchain on|off` (default ON, DIV-69, ELEM 4122). `kuna_orchain.rs (shortcircuit_shared_targets)` replays collapse_conditions read-only on the bblocks CFG, mirroring ruleBlockOr's own admission test rather than approximating it (one in-edge, two out-edges, not a switch, not BlockBasic::isComplex, a shared out-target, sibling's other target is not the head), and `returndup_apply` declines the whole function's splits when one of its own candidates is a recorded target. It also protects a block joining two or more single-exit arms that are themselves fold targets, because the first returndup invocation of the fullloop still sees the constant-materialisation blocks in between. Sweep over the same corpus (base = shipped defaults at merge-base 82dd39a): O0 +611 GED-perfect / -2,816 GED, O2 -13 / +1,232, O2-noinline -15 / +617 -- +583 net and -967 aggregate, 781 functions to perfect against 198 off (3.94 : 1). That is 92% of the +630 the post-hoc "a short-circuit was lost" signal prices as a ceiling, at a smaller optimized-level cost than the ceiling itself (-28 vs -35). Predicate fidelity to that signal: 2,933 of 2,951 O0 positives recognised (99.4% recall) at 126 further firings (95.9% precision); 94.2% of firings reproduce the `option returndup off` body byte for byte. Default-ON rather than an `aggressive` preset member because `returndup` is a shipped default in every mode and 45% of the corpus (38,216 of 85,195 functions, 36 of 795 slices) is over the 500 KiB `auto` threshold and runs `reliable`, where a preset-only gate never runs -- measured: with the gate in the preset only, the no-option arm reproduced the ungated body on iproute2 ip (76 functions), bash (366), sshd (201). 675/675 PARITY OK with the raw flip, zero assertion movement and no per-test opt-out; stages 415/415 with the new two-pass tests/stages/ghdec-orchain.xml; rust-test 4,540 passed / 0 failed; check-spec OK lenient + strict; catalog --check OK. Speed worst +1.01% (two of four probes are net speedups). Rebased onto #280 (funcboundflow, DIV-67): every shared counter re-derived from the built artifact on the rebased tree (97 settables, tiers 20/43/34, xml corpus 195), and DIV-68 was renumbered to 69 after Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
…chain of a short-circuit (DIV-69) (#285) * [AUTOMATED] feat(p8): orchain - returndup must not split the operand chain of a short-circuit (DIV-69) DIV-54 flipped `returndup` on evidence from two of the three optimisation levels. Extended to all three (795 slices / 85,195 scored functions) the pass is +640 GED-perfect corpus-wide but -192 at -O0, and one sub-shape carries essentially all of that harm and almost none of the optimized benefit: the split that permanently blocks `CollapseStructure::rule_block_or`. `returndup` gives every predecessor of a shared bare-epilogue RETURN its own private return. For a guard clause that recovers the source; but the operand blocks of a short-circuit expression are predecessors of that same block, and the shared out-target IS ruleBlockOr's entire precondition. ActionReturnDup runs in fullloop's `returnsplit` group and collapse_conditions runs later, so the fold is lost for good and one source `return a || (b && (c || d));` prints as a five-return constant-guard cascade (iproute2 ip::sci_complete, GED 21 against 0). New option `orchain on|off` (default ON, DIV-69, ELEM 4122). `kuna_orchain.rs (shortcircuit_shared_targets)` replays collapse_conditions read-only on the bblocks CFG, mirroring ruleBlockOr's own admission test rather than approximating it (one in-edge, two out-edges, not a switch, not BlockBasic::isComplex, a shared out-target, sibling's other target is not the head), and `returndup_apply` declines the whole function's splits when one of its own candidates is a recorded target. It also protects a block joining two or more single-exit arms that are themselves fold targets, because the first returndup invocation of the fullloop still sees the constant-materialisation blocks in between. Sweep over the same corpus (base = shipped defaults at merge-base 82dd39a): O0 +611 GED-perfect / -2,816 GED, O2 -13 / +1,232, O2-noinline -15 / +617 -- +583 net and -967 aggregate, 781 functions to perfect against 198 off (3.94 : 1). That is 92% of the +630 the post-hoc "a short-circuit was lost" signal prices as a ceiling, at a smaller optimized-level cost than the ceiling itself (-28 vs -35). Predicate fidelity to that signal: 2,933 of 2,951 O0 positives recognised (99.4% recall) at 126 further firings (95.9% precision); 94.2% of firings reproduce the `option returndup off` body byte for byte. Default-ON rather than an `aggressive` preset member because `returndup` is a shipped default in every mode and 45% of the corpus (38,216 of 85,195 functions, 36 of 795 slices) is over the 500 KiB `auto` threshold and runs `reliable`, where a preset-only gate never runs -- measured: with the gate in the preset only, the no-option arm reproduced the ungated body on iproute2 ip (76 functions), bash (366), sshd (201). 675/675 PARITY OK with the raw flip, zero assertion movement and no per-test opt-out; stages 415/415 with the new two-pass tests/stages/ghdec-orchain.xml; rust-test 4,540 passed / 0 failed; check-spec OK lenient + strict; catalog --check OK. Speed worst +1.01% (two of four probes are net speedups). Rebased onto #280 (funcboundflow, DIV-67): every shared counter re-derived from the built artifact on the rebased tree (97 settables, tiers 20/43/34, xml corpus 195), and DIV-68 was renumbered to 69 after Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH * [AUTOMATED] chore(p0): re-derive the shared counters and re-record the stages baseline Rebased onto #278/#281/#283/#284. Every shared counter re-derived from the BUILT artifact rather than by arithmetic: live catalog 101, phases.toml 101, catalog_bytecompat.rs 101, kuna_phases/tests.rs 101 / tiers (21, 45, 35) / `},\n` 100, phase_catalog.json 101 (recaptured), docs/options.md 101 (regenerated), xml.rs corpus 199, kuna-catalog.xml structure-recovery 26. Stages baseline re-recorded on the merged base: 425 -> 433, +8 orchain keys and the #7 text update, nothing removed. DIV-69 re-checked against origin/main immediately before pushing: main's highest row is DIV-68 (#277), so 69 stands unrenumbered. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Sep 3, 2026
…l the build `ElementId`'s `PartialEq` is an id comparison (ported from C++), so two options sharing an id compare EQUAL and the first code that dispatches on one takes the wrong branch. Three ids were allocated twice on main: 4110 iteregion / returndup (one commit, 2026-07-10) 4122 funcboundflow / orchain (a day apart, #280 and #285) 4132 varargstackargs / linuxsyscall (THIS ROUND -- two concurrent builders) The later of each pair is renumbered: returndup 4135, orchain 4136, linuxsyscall 4134. Renumbering is free here because nothing consumes any of them -- `grep ELEM_ITEREGION` etc. finds only the declaration -- which is also precisely why three of these landed unnoticed. The hazard is the first consumer, not today's output; that is a reason to fix it now rather than a reason not to. Both 4122 sources carried a comment reasoning "the next free id above itecondlist's 4121 is 4122". Two agents grepped for the high-water mark a day apart and got the same answer. 4132 is the same race inside a single round of this pipeline. Reading the high-water mark by hand cannot be made safe, so the comments now point at the deriving tool instead. `counters.py --check` already FOUND duplicates and printed them -- while exiting 0. That is what let all three land, and it is fixed here: duplicates are now a `FAIL` line and a non-zero exit, verified by injecting one. The check is wired into the parity-gates CI job, which is the cheap job that runs on every event, so this cannot recur silently. Gates on the renumbered tree: make test 675/675 PARITY OK · make test-stages PARITY OK · make test-cli 10/10 · make check-spec OK · kuna catalog --check OK · counters --check clean (38 ids, 0 duplicates) · smoke 86/86. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Sep 3, 2026
…iage, and six correctness options (#367) * [AUTOMATED] fix(p4): varargstackargs + calleearity — two ways a call argument was recovered and then discarded RE-friction round 1 filed four "call and argument recovery" observations across three challenges. They are NOT one bug; reproduced and root-caused separately, they are three causes, two of which are call-site argument loss with different owners. Both are fixed here, each behind its own option, each default-ON on a 0/675 ablation and a classified whole-corpus sweep. varargstackargs (DIV-101, P4 active-input-trial-scoring, ElementId 4132) 68149b8a `_main`: scanf("%d") loses its destination and three printf calls lose the buffer their %s consumes, and the local scanf writes ends up read but never written. checkInputTrialUse scores the [sp+0] trial ACTIVE; ParamListStandard::fillinMap deactivates it again, because on AArch64 x0-x7 and the outgoing stack area are ONE resource section and its two positional rules read the seven registers Apple's arm64 ABI structurally leaves empty between the fixed parameter and the first vararg as the end of the argument list. The section is now cut in two at its first stack trial, gated on the callee being variadic and on the stack area starting at callee-relative offset 0. Sweep: 1 changed function of 3857. calleearity (DIV-102, P4 trial-finalization, ElementId 4133) 69a54bd7 0x1400024a0: the same allocator wrapper renders sub_140008160(0x28) at one site and sub_140008160() thirty bytes later, at the site where the size is also the operand of an MSVC operator new[] overflow guard -- only_op_use rejects the trial on its CPUI_CBRANCH descendant. Relaxing that rejection would fabricate an argument at every `test rcx,rcx; jz; call`, so buildInputFromTrials instead reconciles a call whose argument list came out EMPTY with a sibling call to the same callee whose list is already final. The storage is recorded on the call spec, because a CALL op's inputs carry argument values (0x28 is a constant) and the trials that knew the location are deleted one statement later. Sweep: 25 changed of 3857, no regression; the first cut ("same callee, same arity") changed 43 and produced Sleep(200,0), which is where the empty-list condition comes from. Its acceptance probe flips. Gates: make test 675/675 PARITY OK (docs/baseline.json untouched) · make test-stages 578/578 PARITY OK · make rust-test 334 targets / 5018 passed · make check-spec OK · kuna catalog --check OK · counters re-derived, no drift. Speed flat for both, measured on interleaved child CPU time with a null control because the box carried load average 11-14 throughout. Bundles: docs/features/varargstackargs/, docs/features/calleearity/. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [AUTOMATED] feat(cli+analysis): strings, disassemble, function triage, and four correctness options Round 1 of the RE-friction loop: three codex testers on nine crackmes filed 26 observations; 23 passed the two-arm gate. This lands the fixes for them. Interface (Track T) -- five testers across four challenges independently asked for a string inventory, three for disassembly, two for whole-binary triage: kuna strings VMA + section + owning function, which strings(1) cannot give kuna disassemble named function, bare address, or range; --json carries bytes kuna functions --summary --filter --reachable-from --min-size --sort --limit (211 KB PE: 174 KB of JSON -> 2.8 KB that answers "start where") Correctness (Track D), each behind a named option with a two-pass stage test: unmappedentry ON a direct CALL target outside every executable range became a DiscoveredFunction; the instruction worklist had already refused to decode it. 250-binary sweep: 150 phantom entries removed, 0 added, 1 function's C changed and it improves. entrymainproto ON main typed void(void); parameters are recovered from the callee's own body and main never reads its argument registers, so the in-image CRT call site is read instead. linuxsyscall OFF int 0x80 rendered as an indirect call through swi(0x80) switchselector OFF loweredswitch detects a cascade on the simplified graph and installs the BRANCHIND on re-lifted raw p-code it cannot re-find the selector in -- and commits regardless, so a Win32 dialog dispatcher rendered switch(0), every case dead tests/cli grows 5 -> 10 promoted acceptance probes, run by make test-cli in CI. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [AUTOMATED] chore: re-derive shared counters after the merge, and close two guard gaps Counters after merging both lanes: 133 settables (30 core / 54 transform / 49 analysis), stage corpus 228, catalog records 132. Neither branch's number: this branch said 131 and callargrecovery said 129, both having bumped from 127. Every site was re-derived from the live tree with `counters.py --fix`, and phase_catalog.json / docs/options.md / docs/baseline-stages.json were REGENERATED rather than merged. Two guards were blind and are now not: - `counters.py` had no site for the catalog-record assert in kuna_phases/tests.rs (`json.matches("},\n").count()`), so the merge left it at 130 against a truth of 132 and only `make rust-test` caught it. Added as its own site with a `settables_minus_one` derivation -- a regex pinned to `settables` would have written the wrong number. Verified it catches injected drift. - `smoke.sh` asserted the literal strings `"settables": 127` and `"corpus_files": 222`, so every option that lands broke the smoke. That is a false alarm that teaches people to ignore the smoke, and it never caught a real drift because `counters --check` is what does that. It now asserts the mechanism: the derivation is plausible and every hard-coded site agrees with it. Gates: make test 675/675 PARITY OK (baseline.json untouched) · make test-stages 594/594 PARITY OK · make rust-test 339 targets, 5203 passed, 0 failed · make check-spec OK · kuna catalog --check OK · make test-cli 10/10 · tools/repipe/smoke.sh 72/72. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [AUTOMATED] chore(re-needs): file round 1 -- 8 closed, 6 carried into round 2 The backlog was empty because round 1's observations were gated straight from the reports; the records are what round 2's tester brief is rendered from, so without them the next testers would re-file "kuna has no strings command" against a kuna that now has one. Closure is the VERIFIED state, from re-running both arms on the merged build: 8 closed (12 of the 23 gated observations, several of them duplicates of each other), 6 carried open. `void-callee-spurious-arg` is carried OPEN despite its probe no longer matching -- the probe pinned `_secret_function(v2);` and the build now emits `_secret_function(v3);`, which is the same defect with one renumbered local. Also fixes the renderer: `_recently_shipped` printed each closed need's TITLE, which states the problem ("kuna cannot list strings"), under a heading that says "newly available capabilities" -- telling the tester the exact opposite of the truth. It now renders the `Shipped:` line the record carries, so the brief names the flag or subcommand to actually exercise. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [AUTOMATED] docs(re-pipeline): record that a CONFLICTING PR runs no gates and looks green Round 1's own PR hit this: six green CodeQL checks, the Tests workflow with no run object at all, and `gh pr checks` presenting an all-green list. GitHub does not dispatch `pull_request` workflows while it cannot compute the merge commit. The `missing` arm of open_pr.sh --merge -- written for a renamed check -- is what stands between that and an auto-merge of wholly ungated code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [AUTOMATED] fix: three duplicate ElementIds, and make a duplicate fail the build `ElementId`'s `PartialEq` is an id comparison (ported from C++), so two options sharing an id compare EQUAL and the first code that dispatches on one takes the wrong branch. Three ids were allocated twice on main: 4110 iteregion / returndup (one commit, 2026-07-10) 4122 funcboundflow / orchain (a day apart, #280 and #285) 4132 varargstackargs / linuxsyscall (THIS ROUND -- two concurrent builders) The later of each pair is renumbered: returndup 4135, orchain 4136, linuxsyscall 4134. Renumbering is free here because nothing consumes any of them -- `grep ELEM_ITEREGION` etc. finds only the declaration -- which is also precisely why three of these landed unnoticed. The hazard is the first consumer, not today's output; that is a reason to fix it now rather than a reason not to. Both 4122 sources carried a comment reasoning "the next free id above itecondlist's 4121 is 4122". Two agents grepped for the high-water mark a day apart and got the same answer. 4132 is the same race inside a single round of this pipeline. Reading the high-water mark by hand cannot be made safe, so the comments now point at the deriving tool instead. `counters.py --check` already FOUND duplicates and printed them -- while exiting 0. That is what let all three land, and it is fixed here: duplicates are now a `FAIL` line and a non-zero exit, verified by injecting one. The check is wired into the parity-gates CI job, which is the cheap job that runs on every event, so this cannot recur silently. Gates on the renumbered tree: make test 675/675 PARITY OK · make test-stages PARITY OK · make test-cli 10/10 · make check-spec OK · kuna catalog --check OK · counters --check clean (38 ids, 0 duplicates) · smoke 86/86. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [AUTOMATED] chore(re-needs): seed round 2 with the analysis-override gap A source survey of what an agent can OVERRIDE (as opposed to query) found that kuna has a working console vocabulary for exactly the levers an obfuscated binary needs -- `map function`, `map address`, `parse line`, `override flow`, `rename`, `retype`, `map param/return`, `comment instruction` -- and the `kuna` binary can reach none of it. `decompile.rs::build_script` emits a fixed vocabulary and there is no `kuna console`, no `--script` and no passthrough. Three further findings, all verified by running the commands: - `function F spans [start,end)` does not exist anywhere. Extent is derived in funcextent.rs with no override, and phases.toml has no subphase for function-entry identification at all. - The structuring overrides phases.toml advertises in its own `exposure` fields are mostly stubs: `force goto`, `override jumptable` and `structure blocks` all return `engine integration not yet ported`. Only `override flow` works. - `--kassert` is the interface that was meant to carry this, and only its `naming-policy` and `Option` dispatch arms do real work. Four needs seeded, top of the backlog. They are NOT tester-filed and say so; round 2 confirms the demand. The hypothesis section records the thing a builder must not assume: the cheap half is exposure and the expensive half is the stubs, and a scriptable console is a different product from flags an agent composes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude <[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.
What
New
option funcboundflow(P2 flow-classification, default-ON, DIV-67): bound afunction's fall-through at the entry of another known function, so a function whose
last act is a
callto a routine kuna cannot prove no-return does not decode thenext function's body into itself.
Why
A kuna
FunctionSymbolhas no extent and CALL is fall-through, so flow stops only ata RETURN or a provably no-return callee. In a stripped, statically-linked binary the
unnamed
exit/abort/__stack_chk_failbodies and the app-leveldie()/throwwrappers built on them have no symbol to key
noreturn_knownoff and no PLT name fornoreturn_externmatch. The compiler emits their trailingcallwith noret, justalignment padding, and kuna runs the padding's fall-through into the next function's
entry — decoding that function's body into the current one (the following function is
emitted twice: once correctly, once as a garbage tail).
Found by an IDA-vs-kuna study of two static-pie stripped Bee-language runtimes
(
docs/features/funcboundflow/analysis.md): 70/195 (36%) application functions endin exactly such a call. Example —
numeric_item_to_i64 @ 0xa070(.eh_frameFDE0xa070..0xa0a8, last opcall bee_error_throw→exit) swallowed the whole bodiesof
require_numeric_pair @ 0xa0b0andprint_value_lines @ 0xa100. IDA 9.2 and Ghidraboth bound to the function body.
How
p2_lift/kuna_funcboundflow.rs (kuna_should_bound_at_entry)is the decision; thetruncation lives at the fall-through push of
flow.rs (FlowInfo::process_instruction).When the fall-through target is the entry of another known function
(
query_call(next).is_some()) and is not the current function's own entry, kuna plantsa no-return artificial RETURN (mirroring
check_for_flow_modification) and emits afuncboundflowtruncation warning. The gate is fast-pathed (default-off = zeroper-instruction symbol lookups). It overlaps
noreturn_extern/noreturn_externmatchbut is name-independent — it bounds at the function boundary whatever the callee.
Gates
make test675/675 PARITY OK, no baseline re-pin. Two tests that deliberatelyflow into an adjacent function opt out per-test (
longdouble, alreadytailcalljump off;ghangr-noreturn_extern, alreadynoreturn_externmatch off).make test-stages407/407 PARITY OK — new two-passtests/stages/funcboundflow.xml.make rust-testgreen (I am the gate for this on internal-branch PRs). Threeoverlapping-mechanism control tests updated to also disable
funcboundflow; count/tier/fixture bumps (settables 95→96, transform tier 41→42, surfaces 101→102, corpus 193→194).
make check-specOK;kuna catalog --checkOK; catalog counters all 96.targets faster (interp-bee subset 2.62 s vs 5.49 s), normal targets within noise.
🤖 Generated with Claude Code
https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj