Repository navigation
[AUTOMATED] fix(p3): calloverlap - complete the two stubbed upstream call-overlap guards (GH-275) - #284
Merged
Conversation
This was referenced Aug 11, 2026
…call-overlap guards (GH-275) Squashed from the branch's four commits (the fix, the two catalog-count bumps, the flip-guidance prose and the post-funcboundflow reconciliation) so the merge train replays one commit instead of four rounds of the same shared-counter edit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH
…e stages baseline Rebased onto #278/#281/#283. Every shared counter re-derived from the BUILT artifact rather than by arithmetic: live catalog 100, phases.toml 100, catalog_bytecompat.rs 100, kuna_phases/tests.rs 100 / tiers (21, 44, 35) / `},\n` 99, phase_catalog.json 100 (recaptured), docs/options.md 100 (regenerated), xml.rs corpus 198. `kuna-catalog.xml` structure-recovery stays 25 because calloverlap is a correctness-fix, not a structure-recovery row. Stages baseline re-recorded on the merged base: 419 -> 425, +6 CALLOVERLAP keys, none removed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH
mahaloz
force-pushed
the
fix/gh275-packedcallarg
branch
from
August 11, 2026 22:38
e67f01a to
467fafe
Compare
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
…e 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
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
Aug 17, 2026
…ll (#315) [AUTOMATED] GH-275's headline symptom, scoped as defect (A) in PR #284: on x86-64 SysV no xmm register is callee-saved, so a floating-point value that is both an argument and live across the call MUST be spilled by the caller - and that spill is a second descendant of the very Varnode the input trial is scoring. `Funcdata::only_op_use` rejects on any CPUI_STORE, `check_input_trial_use` calls `mark_inactive` (which also sets CHECKED, so the trial is never re-scored), and the argument's producer dies to DCE. New settable `spillargtrial off|reload|spill`, default off. At `reload` a frame STORE stops rejecting only when it writes the walked Varnode's own value into a caller-frame slot AND a later LOAD reads that slot back at the same width; at `spill` the reload requirement is dropped. Since ActionActiveParam runs before ActionStackPtrFlow the frame reference is still the raw INT_ADD(sp, #const), and the reload straddles the call that re-defines the stack pointer, so the search walks forward from the store's own base Varnode carrying the running offset delta rather than matching raw constants. This is a deliberate divergence from upstream, not a port repair: the rule it relaxes exists to stop an ordinary frame store from becoming a bogus argument. No DIV row - the shipped default does not change. Claude-Session: https://claude.ai/code/session_01VBn8vgwoHqPFnnV4ZMApfq Co-authored-by: Claude Fable 5 <[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.
Completes the two partial-range call-overlap guards kuna shipped as comment-only
stubs, behind
option calloverlap off|in|full(defaultoff). Filed againstGH-275, which it partly — but explicitly not fully — closes; the issue stays open
and carries the full decomposition as a comment.
GH-275 is three defects, not one
Traced end to end (instrumented
Heritage/ParamActive/only_op_use, one-bytecausal ablations on the filed binary, and a re-run of Ghidra 11.4.3 with
atan2'simported signature stripped so both decompilers see the same unknown callee).
Funcdata::only_op_usereturning false on itsCPUI_STOREarm,substrate/funcdata_varnode.rs:2258-2265(STORE at:2263) — the argument varnode has a second descendant, the caller's own 16-byte spillmovapsis packed-single, four 32-bit lane writes (ia.sinc:7287), soHeritage::refinementpartitions XMM1 at 4-byte boundaries and the float pentry isminsize="4"; no re-join becauseActionParamDoubleis a no-op stub (p4_calls/coreaction_protos.rs:1017)copysignvariant's zero argumentsp3_dataflow/heritage.rs:1523-1525(input) and:1470-1475(output), both comment-only stubsThe obvious hypothesis is dead: in every failing trial
AncestorRealisticreturnsrealistic=true, solid=true. The rejector in (A) isonly_op_use, downstream of apassing realism check.
Upstream calibration: A and B are Ghidra's behavior too
Ghidra 11.4.3 on the unmodified
packed_two_atan2withatan2stripped toundefined atan2(void):So (A) and (B) are upstream-faithful, not kuna regressions — Ghidra only gets the
filed binary right because it applies an imported
double atan2(double,double), and alocked prototype makes
FuncCallSpecs::isInputActivefalse, bypassing trial recoveryentirely. (C) is the one place kuna was worse, and it emitted a wrong value, not
merely a missing one.
The trigger is not packed-double, not float, not SIMD
The predicate is any whole-width write to a register holding an ABI parameter or
return entry: that write blocks
Heritage::refinement(gatesize > 4 && maxw < size),so the range stays
ContainedByand the whole-range guards see nothing. In the vendoredia.sinc,PXOR,POR,PAND,MOVDQA,MOVDQU,MOVQ-to-xmm andORPDare allsingle 128-bit writes (
MOVAPD/ANDPD/XORPDare two 8-byte lanes — one byte separatesa working case from a broken one).
orpd, the instruction GH-275 was filed on, is 2 of2,703 occurrences of the shape.
Five lines of plain C at
gcc -O2— no intrinsics, no SIMD, no libm — reproduce it, andthey are the stage test's vector:
The change
decompiler/crates/kuna-decomp/src/p3_dataflow/heritage.rs— three methods portedverbatim from upstream:
Heritage::guard_call_overlapping_input(C++heritage.cc:1210)Heritage::try_output_overlap_guard(C++heritage.cc:1249)Heritage::guard_output_overlap(C++heritage.cc:1293) — not the existingguard_output_overlap_stack: the register form makes every piece an INDIRECTcreation, where the stack form pulls the flanking pieces off a pre-call value.
The input branch of
guard_callsis also restructured to upstream's nesting. kuna hadcollapsed it to
if (ic == ContainsJustified && whichTrial(...) < 0), so a naiveelse iffor theContainedByarm would have fired on a range that is notContainedBywhenever a trial already existed. Upstream'selse iftests thecharacterization alone.
FuncProto::get_biggest_contained_input_param(p4_calls/fspec.rs:5880) endsreturn res.size == 0;, which reads inverted —fspec.cc:4482is literallyif (locktest) return (res.size == 0);. kuna's port is faithful; left alone.What is closed and what is not
calloverlap fullgcc_pxorf(plain gcc -O2 pxor)float8 f(void) { u(); sink = v1; return v1 + dat_2008; }(v1never assigned)float8 f(int8 a0) { sink = (float8)u((float8)a0); return sink + dat_2008; }— exact Ghidra paritypacked_copysign_atan2atan2(); ... atan2(v2,v2); return v2 + a0;atan2(v6); ... atan2(v6,v3 | v4) + v2— exact Ghidra paritytwo_orpdatan2(); atan2(a0,v3); return a0 + a0;realmixvoid mix(void) { scale(); }void mix(int4 a0) { scale((float8)a0); }(partial)packed_two_atan2(GH-275's own binary)The last row is a required negative control and it holds: GH-275's headline symptom is
defect (A), which Ghidra shares, so
calloverlapdoes not close it.Corpus sweep, both directions
All 268 decbench O2 stripped binaries (231 x86-64, 33 ARM Cortex-M, 4 PE32),
77,014 functions, one
kuna decompile-all --jsonper (binary, arm), every changedfunction text-diffed and classified:
infullPer architecture at
full: x86-64 217/59,378, ARM Cortex-M 66/17,327, PE32 0/309. Aseparate pass over the 20 non-x86-64
kuna-analysisfixtures (aarch64, arm, riscv64,mips LE and BE, sparc64 BE, ppc64le, i386; 323 functions) changed nothing — so
the big-endian
slot_newflip inguard_output_overlapis transcribed from upstreambut remains unexercised by any test I could find.
Hand-audited samples, both directions:
findsub_86e0:__fprintf_chk(a0,1," [est success rate %.4g] ")-> the same callwith
(float8)*(float4 *)(a1 + 0x24). The format string is the ground truth.bzip2sub_3890(compressStream):void sub_3890(unsigned long a0,void *a1,void *a2)->
void sub_3890(void *a0,void *a1)(the real signature is twoFILE*), theBZ2_bzWriteClose64call goes 5 -> 7 arguments (its real arity), and the summary__fprintf_chkgoes 4 -> 5 varargs for 5 conversions.sshsub_91960,wc/sortphysmem_total:sub_X(); return v1;withv1neverassigned ->
return sub_X();.df/chcon/chgrp/...sub_88c0renders a formerly scalarfloat4 v9aschar v9 [16]withv9[0] = ...; SUB164(v9,0)lane traffic — faithful, noisier.the format string (
log_out((float8)x,(float8)y,a0,"time: %5.2f/%5.2f/%5.2f\n")),because
build_input_from_trialsdoes not interleave the integer and floatParamEntry groups back into source order for an unprototyped mixed call.
GED (
scripts.decbench.optsweep, O2, 10 projects, 10,036 scored functions, controlsclean — 9,968 unchanged bodies all scoring identically, 99.8% baseline agreement):
to-perfect 1, off-perfect 0, improved 2 / worsened 5, aggregate dGED +21. Topology is
essentially neutral: GED is blind to arity, and the few movements are the lane-array
if/else expansion adding CFG nodes (
find/do_fprintf29 -> 44) againstgzip/display_ratio10 -> 0 (perfect) andtar/format_total_stats77 -> 69.Speed
Interleaved A/B, alternating arm order per iteration, measuring child CPU time
(
getrusage(RUSAGE_CHILDREN)) as well as wall clock — this box is shared with otheragents, and wall clock alone is unusable here.
coreutils/sortdecompile-allcoreutils/wcdecompile-allWell inside the 5% budget. The quiet-box
sortrun is the number to trust; an earliersortrun at N=11 under load 21 returned min -12.65%, which is impossible for achange that can only add work and is exactly the noise the campaign notes warn about.
Cost is structurally small because the guards fire only on
ContainedByranges, whichis 0.37% of functions.
Why default
offThe flip would clear the repo's stated bar — with the option forced on over every test
file,
make testis 675/675 PARITY OK andmake test-stagesis 411/411 PARITY OK(a control injection of an invalid value proves the injected command really executes),
there are zero new decompile errors over 77k functions, and the correctness ledger is
94:6 in favour. It is left off anyway because the sweep turned up two ways the
guards make output worse on the functions they touch, both of them pre-existing kuna
defects the guards merely expose:
Neither is visible to any of the four gates. They should be fixed first; then the flip is
a one-line change plus a DIV row, and this PR body is its evidence package. Not added to
AGGRESSIVE_OVERRIDESfor the same reason (autopicks aggressive under 500 KiB, whichwould make it the de facto default).
inis a bisect level, not a recommendation: recovering the argument without recoveringthe return value is net-negative on use-before-def (12 introduced against 10 fixed).
Gates
Run on the rebased tree (
origin/main=11f40f46, funcboundflow), afterre-deriving every shared count from a green build of this tree.
docs/baseline.jsonis untouched.docs/baseline-stages.jsonis re-recorded (nothand-merged) for the six new assertions, 407 -> 413. Shared counts, all derived from
this tree rather than computed: settables 95 -> 97, tiers (20,41,34) -> (21,42,34), stage
corpus files 193 -> 195, the mid-table
},\ntally 94 -> 96, and the no-program catalogfixture regenerated. Two further count sites the plan did not list also needed bumping:
option_values_live_value_present_for_*(calloverlap's live reader is console-side, likecppsig's, so it belongs in the codegen-suppressed allowlist) andemit_catalog_json_static_form_brackets_and_commas.No
docs/history.mdDIV row: the shipped default does not change.What remains:
spillargtrial(scoping, no PR yet)Mechanism. GH-275's headline symptom is defect (A). The argument varnode reaching the
call has a second descendant — the caller's own
movapd XMMWORD PTR [rsp+0x20],xmm1spill — so
Funcdata::only_op_usehits itsCPUI_STOREarm(
substrate/funcdata_varnode.rs:2263) and returns false,check_input_trial_use(
p4_calls/funcdata_callsite.rs:186->:196) marks the trial inactive,mark_inactivesets CHECKED so it is never revisited (
:80), and the chain dies to DCE. The candidatechange is to narrow that arm: a STORE whose value operand
in(2)is the walked varnodeand whose pointer is a caller-frame stack slot does not set
res = false— optionallyrequiring a later reload of the same slot into the same register, i.e. a genuine
caller-save spill/reload pair (both GH-275 repros have one; hand-written asm probes
mostly do not, so the two predicates are separable and should be A/B'd).
Risk. This is a deliberate divergence from upstream, not a bug fix — kuna's
only_op_useis byte-faithful tofuncdata_varnode.cc:1891, and the blanket STORErejection exists precisely to stop a caller-saved value spilled just before a call from
becoming a bogus extra argument. Relaxing it admits non-arguments: any local written to
the frame in the instructions before a call now looks like a parameter. The failure mode
is a spurious trailing argument, which no gate can see (the datatests are
prototype-declared, and GED is blind to arity).
What would have to be measured. The same bidirectional sweep as above, plus: (a) the
spurious-argument rate, by sampling newly-appearing trailing arguments against the
disassembly at both predicate strengths (bare STORE-value vs. requiring the reload);
(b) the arity-shortfall rate against kuna's own recovered callee signatures, which must
fall; (c) the four gates and a speed delta, since the change increases the number of
active trials that survive to
buildInputFromTrials. Default-off regardless, and itneeds its own DIV row if it is ever flipped.
Not opened as a second PR: the predicate choice is unresolved and the false-positive
surface is exactly the thing upstream's rule guards against, so it wants its own
measurement round rather than being bolted on here.
🤖 Generated with Claude Code
https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH