Repository navigation
[AUTOMATED] fix(p6): (NOVEL) no $$undef placeholder survives the naming pass (DIV-58) - #257
Merged
Merged
Conversation
…ng pass (DIV-58) An identifier containing `$$` was reaching emitted C, and it was not cosmetic: the placeholder was a SECOND identifier for a stack Symbol already declared under its `vN` name, so the body read a variable that is never written while the update landed on the other name. In tar `xstrcat` that is the x86-64 va_arg loop testing and incrementing an uninitialised variable. `Scope::buildUndefinedName` (database.cc:2854) names an empty-named Symbol `$$undef` plus 8 hex digits. Upstream it is unobservable because `ActionNameVars::apply` renames every still-undefined Symbol before returning (`localmap->assignDefaultNames(base)`, coreaction.cc:3079) and `PrintC` reads `sym->getDisplayName()` live at emit time. kuna caches the name per HighVariable and its port of `ScopeInternal::assignDefaultNames` had zero call sites, so both guarantees were missing. `ScopeLocal::resolve_default_name_override` renames the covering Symbol only for a whole-symbol cover (the C++ namerec gate `sym->isNameUndefined() && high->getSymbolOffset() < 0`) and otherwise returns the Symbol's current display name. A partial cover sorts first in location order, so it froze the placeholder and its whole-cover sibling then renamed the shared Symbol. The gate is a faithful port and is left alone: relaxing it would move when a Symbol consumes `base` and renumber every later local. Instead `ActionNameVars` grows the tail it was missing (p6_variables/kuna_undefname.rs): wire the catch-all `assignDefaultNames`, then re-resolve every high still holding a placeholder through the same `queryProperties(addr,1,usepoint)` containment query that bound it. Both steps run after every `vN` is handed out and after the spacebase attach pass, so neither renumbers an existing local and every `&symbol` render stays byte-identical. No option: an identifier containing `$$` is not valid C under any naming policy, and the ablation agrees (0 of 675 upstream assertions move). Breadth over 116 stripped binaries / 90,808 functions (x86-64 and ARM Cortex-M, O0/O2/ O2-noinline): binaries emitting a placeholder 73 -> 0, functions 371 -> 0, occurrences 2,142 -> 0 (1,503 reads / 639 writes), Symbol tables carrying one 93 -> 0. Blast radius over 12 binaries / 18,590 functions: 162 functions change and all 162 had a placeholder before; four clean controls are byte-identical. GED delta 0.0 (a rename cannot move a CFG). Speed worst case +3.33%, inside the +5% budget. Gates: make test PARITY OK 675/675 (docs/baseline.json untouched), make test-stages PARITY OK 394/394, make rust-test 4,427 passed / 0 failed, make check-spec OK, kuna catalog --check OK. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz
force-pushed
the
fix/decbench-undefname
branch
from
August 3, 2026 14:12
645f326 to
8a721ce
Compare
mahaloz
added a commit
that referenced
this pull request
Aug 3, 2026
…cost this round Docs-only. No .rs, no phases.toml, no baselines, no tests. Rebased onto origin/main 4c2b59b (after #254, #255 and #257). Round 2 shipped, and the benchmark signal was refreshed on 2026-08-03 (all three opt levels re-decompiled from pinned kuna 9623dc2). Several documented claims were provably stale and several hard-won operational facts existed only in agent transcripts. Both fixed, every number re-verified against the live tree. docs/decbench-loop.md - Standings replaced and widened: GED ida 36.06 / kuna 35.93 / angr 34.20, overall ida 38.01 / kuna 37.91 / angr 36.98, byte_match kuna 3.41 (first). Stated plainly that kuna's column is current while the rivals' are from their own last runs, so the tree is a MINING INSTRUMENT, not a leaderboard. - Recall pool: 6,540 (7.3%) -> 1,420 vs angr / 1,552 vs ida, 0 whole-binary failures, now almost entirely embedded ARM Cortex-M. All three named causes corrected: "u-boot 100% / freertos 100%" was a decbench .text-filter artifact and never a kuna discovery failure (angr and ida score nothing there); "betaflight 22%" is 6.0%; the coreutils `main` empty-body/panic is fixed (comm/join/timeout/uniq all produce full bodies today). - The `--mode auto` degrades-to-fast warning is moot for this corpus: the largest stripped binary is O0 bash at 1,513,904 B (1.44 MiB), so all 803 binaries resolve 768 aggressive / 35 reliable / 0 fast. The aggressive-vs- reliable distinction is kept and sharpened; the stale 21-of-24 default-off count is now 20 of 25, with the five exclusions named. - Two operational traps recorded for the first time: (a) byte_match RECOMPILES with an arch-matched toolchain and this box has neither arm-none-eabi-gcc nor MinGW, so deleting kuna's (never auto-invalidated) checkpoints destroys kuna's ARM/PE scores while every rival keeps theirs. The coverage guard caught 34 slices; O2 and O2-noinline are still damaged from an earlier DECBENCH_ALLOW_DROPS=1 run with no surviving copy. Rule: never pass DECBENCH_ALLOW_DROPS=1 without reading every [guard] line. (b) The pools store a PE address as an RVA where kuna uses the VA, so scripts.decbench.rescore fails on every PE case (119 across the three pools). Recorded with a fix direction. - Pointed at the durable refresh recipe at ~/decbench-campaign-state/ and its two pinning rules, plus the non-obvious one: the GED baseline must drop kuna's published scores for EVERY re-decompiled opt level, not just the one being refreshed (an O0-only baseline died with "cannot reproduce published fallback 58.0" on an O2 slice). Method corrections (decbench-loop.md + improvement-pipeline.md standing rules) - "Not a no-op" is not "correct". On paramcopyhoist a refuter proved the proposed hook reached the printer and it was still the wrong site: it deleted an assignment, lost an early return, and made another function return the wrong parameter. The refute brief now carries an explicit "would this produce WRONG output?" axis. - Diff every changed function, not the witness. Those designs all passed on their witness. Round 2's PRs swept 3,031 / 12,241 / 14,720 / 15,386 functions; two caught real problems that way. - The tally, honestly: round 1's filed mechanisms were 2-for-5, round 2's refuters overturned the filed diagnosis on 3 of 8, and the symptom stood in every case. Shared counters in a busy queue (decbench-loop.md + improvement-pipeline.md) - Round 2 ran up to four output-changing PRs over the same hard-coded counters and produced three failure shapes, only one of which announced itself: a conflict (#257's DIV number raced 55 -> 56 -> 57 -> 58); a SILENT identical-edit auto-merge (catalog_bytecompat.rs kept 86 because both sides made the same 85 -> 86 edit); and a SILENT keep-both auto-merge (a stale baseline-stages.json data_footer, and five rounds of keep-both duplicating a row in tests/stages/README.md). - Rules written down: derive every shared counter from a fresh capture and a green run on the rebased tree, never by arithmetic; diff every keep-both resolution against main asserting you removed nothing and added nothing twice; DIV numbers are claimed on merge; re-run the gates AFTER the rebase. - New standing requirement 9: re-measure after every rebase, never carry a number forward. #257's placeholder count moved 2,143 -> 2,142 because #254 landed underneath it, caught only by re-measuring. docs/decbench/features.md - Round-1 menu replaced by round-2 outcomes, keeping the file's shape and its rank-by-correctness thesis. NINE merged PRs: #248 cortexmvectors, #249 funcptralign, #250 paramcopyhoist, #251 subright, #252 returncopysplit, #253 itecondlist, #254 peimportcall (DIV-57), #255 ptrentry and #257 undefname (DIV-58) -- seven of the eight round-2 candidates plus steps 1 and 2 of the ARM entry-recall sequence (#239). Only three of the nine move GED on a mined case; four are correctness fixes the metric cannot see and two are recall. - The dead-pass finding is now three DISTINCT shapes to grep for, not one anecdote: stub body (RuleSubRight), live body with a permanently-zero input (RuleFuncPtrEncoding's hard-coded funcptr_align() = 0), and live body with a gate bit that has no writer anywhere (ActionDeindirect / externref). The third had a second gap in the same chain -- GlobalEntry::func_no_return never copied the callee's no-return flag into the snapshot -- so one dead gate can hide another. - The ARM sequence is cross-referenced to the live table on PR #239 rather than duplicated here, so it cannot go stale in-repo. - Carried forward as the one still-open candidate: catalog-upstream-options (38 upstream-inherited ArchOptions invisible to `kuna catalog`). Re-mined pool tables regenerated against the refreshed tree (snapshot 2026-08-03): backlog.md, backlog-ida.md, novel.md, triage-queue*.json. Gates on the rebased base: make check-spec OK (lenient and strict); make test 675/675 PARITY OK; make test-stages 394/394 PARITY OK. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz
added a commit
that referenced
this pull request
Aug 3, 2026
…cost this round (#256) Docs-only. No .rs, no phases.toml, no baselines, no tests. Rebased onto origin/main 4c2b59b (after #254, #255 and #257). Round 2 shipped, and the benchmark signal was refreshed on 2026-08-03 (all three opt levels re-decompiled from pinned kuna 9623dc2). Several documented claims were provably stale and several hard-won operational facts existed only in agent transcripts. Both fixed, every number re-verified against the live tree. docs/decbench-loop.md - Standings replaced and widened: GED ida 36.06 / kuna 35.93 / angr 34.20, overall ida 38.01 / kuna 37.91 / angr 36.98, byte_match kuna 3.41 (first). Stated plainly that kuna's column is current while the rivals' are from their own last runs, so the tree is a MINING INSTRUMENT, not a leaderboard. - Recall pool: 6,540 (7.3%) -> 1,420 vs angr / 1,552 vs ida, 0 whole-binary failures, now almost entirely embedded ARM Cortex-M. All three named causes corrected: "u-boot 100% / freertos 100%" was a decbench .text-filter artifact and never a kuna discovery failure (angr and ida score nothing there); "betaflight 22%" is 6.0%; the coreutils `main` empty-body/panic is fixed (comm/join/timeout/uniq all produce full bodies today). - The `--mode auto` degrades-to-fast warning is moot for this corpus: the largest stripped binary is O0 bash at 1,513,904 B (1.44 MiB), so all 803 binaries resolve 768 aggressive / 35 reliable / 0 fast. The aggressive-vs- reliable distinction is kept and sharpened; the stale 21-of-24 default-off count is now 20 of 25, with the five exclusions named. - Two operational traps recorded for the first time: (a) byte_match RECOMPILES with an arch-matched toolchain and this box has neither arm-none-eabi-gcc nor MinGW, so deleting kuna's (never auto-invalidated) checkpoints destroys kuna's ARM/PE scores while every rival keeps theirs. The coverage guard caught 34 slices; O2 and O2-noinline are still damaged from an earlier DECBENCH_ALLOW_DROPS=1 run with no surviving copy. Rule: never pass DECBENCH_ALLOW_DROPS=1 without reading every [guard] line. (b) The pools store a PE address as an RVA where kuna uses the VA, so scripts.decbench.rescore fails on every PE case (119 across the three pools). Recorded with a fix direction. - Pointed at the durable refresh recipe at ~/decbench-campaign-state/ and its two pinning rules, plus the non-obvious one: the GED baseline must drop kuna's published scores for EVERY re-decompiled opt level, not just the one being refreshed (an O0-only baseline died with "cannot reproduce published fallback 58.0" on an O2 slice). Method corrections (decbench-loop.md + improvement-pipeline.md standing rules) - "Not a no-op" is not "correct". On paramcopyhoist a refuter proved the proposed hook reached the printer and it was still the wrong site: it deleted an assignment, lost an early return, and made another function return the wrong parameter. The refute brief now carries an explicit "would this produce WRONG output?" axis. - Diff every changed function, not the witness. Those designs all passed on their witness. Round 2's PRs swept 3,031 / 12,241 / 14,720 / 15,386 functions; two caught real problems that way. - The tally, honestly: round 1's filed mechanisms were 2-for-5, round 2's refuters overturned the filed diagnosis on 3 of 8, and the symptom stood in every case. Shared counters in a busy queue (decbench-loop.md + improvement-pipeline.md) - Round 2 ran up to four output-changing PRs over the same hard-coded counters and produced three failure shapes, only one of which announced itself: a conflict (#257's DIV number raced 55 -> 56 -> 57 -> 58); a SILENT identical-edit auto-merge (catalog_bytecompat.rs kept 86 because both sides made the same 85 -> 86 edit); and a SILENT keep-both auto-merge (a stale baseline-stages.json data_footer, and five rounds of keep-both duplicating a row in tests/stages/README.md). - Rules written down: derive every shared counter from a fresh capture and a green run on the rebased tree, never by arithmetic; diff every keep-both resolution against main asserting you removed nothing and added nothing twice; DIV numbers are claimed on merge; re-run the gates AFTER the rebase. - New standing requirement 9: re-measure after every rebase, never carry a number forward. #257's placeholder count moved 2,143 -> 2,142 because #254 landed underneath it, caught only by re-measuring. docs/decbench/features.md - Round-1 menu replaced by round-2 outcomes, keeping the file's shape and its rank-by-correctness thesis. NINE merged PRs: #248 cortexmvectors, #249 funcptralign, #250 paramcopyhoist, #251 subright, #252 returncopysplit, #253 itecondlist, #254 peimportcall (DIV-57), #255 ptrentry and #257 undefname (DIV-58) -- seven of the eight round-2 candidates plus steps 1 and 2 of the ARM entry-recall sequence (#239). Only three of the nine move GED on a mined case; four are correctness fixes the metric cannot see and two are recall. - The dead-pass finding is now three DISTINCT shapes to grep for, not one anecdote: stub body (RuleSubRight), live body with a permanently-zero input (RuleFuncPtrEncoding's hard-coded funcptr_align() = 0), and live body with a gate bit that has no writer anywhere (ActionDeindirect / externref). The third had a second gap in the same chain -- GlobalEntry::func_no_return never copied the callee's no-return flag into the snapshot -- so one dead gate can hide another. - The ARM sequence is cross-referenced to the live table on PR #239 rather than duplicated here, so it cannot go stale in-repo. - Carried forward as the one still-open candidate: catalog-upstream-options (38 upstream-inherited ArchOptions invisible to `kuna catalog`). Re-mined pool tables regenerated against the refreshed tree (snapshot 2026-08-03): backlog.md, backlog-ida.md, novel.md, triage-queue*.json. Gates on the rebased base: make check-spec OK (lenient and strict); make test 675/675 PARITY OK; make test-stages 394/394 PARITY OK. Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL Co-authored-by: Claude Opus 5 (1M context) <[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
An identifier containing
$$was reaching emitted C. Worse than cosmetic: theplaceholder was a second identifier for a stack Symbol already declared under its
vNname, so the body read a variable that is never written while the update landedon the other name.
tarxstrcat(O2,0x611a0) is the sharpest witness -- the x86-64va_argexpansion, testing and incrementing an uninitialised variable:
After:
ipset_qlen(O2-noinline,0x2b420) is the second mechanism -- there theplaceholder is in the Symbol table itself, so it leaked out of the C into the
structured surfaces too:
Full write-up:
docs/features/undefname/analysis.md.Why it happened
Scope::buildUndefinedName(database.cc:2854) names an empty-named Symbol$$undefplus 8 hex digits. Upstream that string is unobservable for two reasons, and kuna
inherits neither:
ActionNameVars::applyrenames every still-undefined Symbol before itreturns -- its last statement is
localmap->assignDefaultNames(base)(
coreaction.cc:3079);PrintCreadssym->getDisplayName()live at emit time.kuna caches the name per HighVariable (
HighVariable::kuna_name), and its port ofScopeInternal::assignDefaultNameshad zero call sites in the tree.Instrumented (a temporary backtrace on
set_kuna_name; notekuna decompileshells outto
decomp_dbgwith stderr piped, so the in-processdecompile-allpath is the oneto instrument):
One Symbol, two highs.
ScopeLocal::resolve_default_name_overriderenames the coveringSymbol only for a whole-symbol cover (the C++
namerecgatesym->isNameUndefined() && high->getSymbolOffset() < 0) and otherwise returns theSymbol's current display name; the 4-byte partial sorts first in location order, so it
froze the placeholder and the 8-byte sibling then renamed the shared Symbol. Nothing
back-filled the first cache. The
--jsonvariablesarray confirms the diagnosisnon-perturbingly: exactly one Symbol at that offset, and no
$$undefSymbol at all-- so the printed placeholder corresponded to no live Symbol, which rules out the
"second Symbol" reading the case was originally filed under.
The gate is a faithful port and is left alone. Relaxing it would move when a Symbol
consumes
baseand renumber every later local. InsteadActionNameVarsgrows the tailit was missing (
p6_variables/kuna_undefname.rs): wire the catch-allassignDefaultNames,then re-resolve every high still holding a placeholder through the same
queryProperties(addr,1,usepoint)containment query that bound it -- kuna's stand-in forthe printer's live read. Both steps run after every
vNis handed out and after thespacebase attach pass, so neither renumbers an existing local and every
&symbolrenderstays byte-identical.
No option
AGENTS.md: "a strict bug fix that only corrects wrong output needs no flag." Anidentifier containing
$$is not valid C under any naming policy (namestyle ghidrareaches the same tail and produces upstream's
xStack<offset>form). The ablationdecided it rather than the argument: 0 of 675 upstream assertions move. DIV-58 (DIV-55/56/57 were claimed by #252/#253/#254 while this branch was in flight; re-check the number at merge).
Breadth (re-measured on this rebase, post-#249 through #254)
One binary per project per optimisation level: 116 stripped binaries / 90,808
functions, x86-64 and ARM Cortex-M,
O0/O2/O2-noinline, watchdog disabled so atimeout cannot blank a function in either arm.
Blast radius
Twelve binaries (the eight leakiest plus four that never leaked, as controls) decompiled
whole in both arms and diffed function by function:
tar(leaky)ip(leaky)e2fsck(leaky)bash(leaky)tar(leaky)ip(leaky)e2fsck(leaky)betaflight_STM32F405.elf(leaky)update-passwd(control)bzip2(control)ch.elf(control)CMSIS_DAP.axf(control)Every changed function had a
$$undefidentifier before; the function set is identicalin both arms (asserted), error-record counts match, and all four controls are byte-identical.
Stack-local declaration lines go 16,828 -> 16,612: once the two names agree, the printer's existing
whole-sibling guard folds the duplicate declaration.
Benchmark
GED scores CFG shape, so an identifier rename cannot move it.
scripts.decbench.rescoreon
O2-noinline-iproute2-ip-netns_add(a case whose stored pane carries the placeholder):before 8.0, after 8.0, delta 0.0, no metric drift. This item came from the NOVEL pool
precisely because it does not rank by margin.
Speed
scripts.pipeline.timeitflips an option on one binary, so it does not apply to adefault-path fix; this is the interleaved two-binary A/B that DIV-52 and DIV-54 used for
the same reason.
decompile-all --mode reliable, whole binary, medians:tar-O2ip-O2-noinlinegzip-O2Worst case +3.33%, inside the +5% budget. The added work is one bounded
nametreerangequery plus one high walk that exits immediately on any function with no placeholder.
Gates (verbatim, on this rebase onto
208bb155)docs/baseline.jsonis untouched.docs/baseline-stages.jsonwas re-recorded, nothand-merged: 386 -> 394, and the diff is exactly this test's 8 new keys plus the footer.
Test
tests/stages/ghdec-undefname.xmlcarries both mechanisms as real bytes with theircallees stubbed. Against the pre-fix build 3 of 8 assertions pass; with the fix,
8/8. Pass 2 sets
option dedupvardecls offto pin that neither witness depends on theP9 declaration collapse -- this is a P6 naming fix, so the off path renders identically.
Findings that correct the record (for the next agent)
1. DIV-52's
collapse_symbol_declsis NOT what folds the duplicate declaration. Thetriage predicted it would, once the two names agreed. It cannot: it is gated on
option dedupvardecls. What actually folds the declaration is the older, ungatedis_scalar_partial_pieceguard (p9_emit/printc.rs), which skips a high that is astrict partial of a scalar mapped Symbol when a whole-cover sibling of the same name
exists -- before this fix the names differed (
$$undef00000000vsv12), so the guardcould never match. Proven, not reasoned: pass 2 of the stage test runs with
option dedupvardecls offand the fold still happens.2.
kuna decompileshells out todecomp_dbgwith stderr PIPED, so engine-levelinstrumentation is invisible on that path. An
eprintln!/backtrace added inside theengine produces nothing when you drive it with
kuna decompile ..., which reads as"my hypothesis is wrong" when it only means "you cannot see it from here". The
in-process path is
kuna decompile-all <binary> --json --addr 0x...-- instrumentagainst that. This has now cost two agents in this campaign real time.
A third, cheaper one: the non-perturbing discriminator for symbol-vs-cache questions is
the
--jsonvariablesarray (extract_variablesreads the ScopeLocal Symbol tabledirectly). The console
renamecommand, which the case was originally filed with,perturbs -- it also deletes the stack-canary locals.
🤖 Generated with Claude Code