Repository navigation
[AUTOMATED] fix(analysis): pe-function-inventory-labels — name a virtual method after the function, not its vftable - #382
Merged
Conversation
…ual method after the function, not its vftable
The MSVC RTTI pass (rtti R3) walks each recovered vftable and emits a
Function symbol at the address every slot POINTS AT — the virtual method.
It named that function `<Class>::vftable_<i>`, so `kuna functions` reported
executable ranges as vtable objects: 10 of them on the round-2 challenge PE,
up to 496 bytes of `std::basic_stringbuf` code. Under multiple inheritance an
MSVC class genuinely owns several vftables, so the indexed form also collides
with the natural reading "this class's i-th vftable". Renamed to
`<Class>::vfunc_<i>`; only the table itself keeps the unindexed
`<Class>::vftable` Data label.
The filed hypothesis ("public data aliases are winning the canonical-name
selection") is overturned: no data symbol is involved, the name is one kuna
synthesises, and function discovery is untouched.
The rename alone regressed one function, and only the whole-corpus sweep
found it. entry_name_rank's tiers are (placeholder, structural,
leading-underscore, LENGTH), so a real method name and a synthetic slot name
were separated by a one-character length accident:
`std::basic_streambuf::showmanyc` (30) beat `vftable_5` (31) and lost to
`vfunc_5` (29), while its neighbour `uflow` kept its name either way. A
slot-index name is structural in exactly the sense the existing `_FINI_<i>`
tier documents — it says which slot the function occupies, not what the
function is called — so `<Class>::vfunc_<i>` and the Itanium sibling's
`<Class>::vtable_<i>` now sort into that tier and a real method name outranks
them at any length. They still beat `sub_`/`FUN_` placeholders.
Sweep: `kuna functions --json --mode aggressive` over 19 targets (9 in-repo
PE fixtures, 8 C++/ELF fixtures incl. the stripped Itanium-RTTI .so, the
fauxware/aif_gap controls, the recorded dataset PE) plus `decompile-all
--json` over the 9 PEs. Residual after normalising `::vftable_<i>` ->
`::vfunc_<i>`: 0 lines. Nothing else moved on any target.
Tooling track: no option, no phases.toml row, no catalog counter, no
tests/stages case.
Acceptance probe flips 10 -> 0 and is promoted to
tests/cli/pe-function-inventory-labels.json, re-pointed onto the in-repo
msvc_rtti_x64.exe (CI has no dataset) with an added positive clause so a dead
rtti pass cannot satisfy it.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Sep 4, 2026
B_DONE bookkeeping for wave 7 of round 2. Acceptance a-d6666365cbb6 (kuna functions --json must not name any executable range <Class>::vftable_<i>) FAILED when the need was filed and PASSES on the gated build fed78ec, so the need flips open -> closed with closing_pr 382 / closed_in_round 2. Gate evidence: /tmp/b_verify_fed78ec3.{rc,log,acceptance.json} at HEAD-pinned fed78ec -- all four gates plus catalog/clitests/acceptance rc=0, 2x PARITY OK, tests/cli 17/17, acceptance suite closed=[pe-function-inventory-labels] regressed=[]. No probe promotion needed: PR #382 vendored tests/cli/pe-function-inventory-labels.json itself (the 16 -> 17 step the gate run confirms). Backlog is now 17 closed / 18 open of 35. Co-Authored-By: Claude Opus 5 <[email protected]>
stefan-siebert
added a commit
to stefan-siebert/kuna
that referenced
this pull request
Nov 16, 2026
…s vtable itaniumrtti emits a Function symbol at the address each sub-vtable slot points at and named it `<C>::vtable_<i>` (`<C>::vtable_for_<Base>_<i>` in a secondary sub-vtable), so `kuna functions` and call sites showed routines under vtable names. The MSVC sibling pass dropped that stem in Noelo-Lab#382 for the same reason. The slot functions are now `<C>::vfunc_<i>` and `<C>::vfunc_for_<Base>_<i>`; the data labels (`<C>_vtable`, `<C>_vptr`, `<C>_vtable_for_<Base>`) are unchanged. is_vtable_slot_name now recognises the secondary-sub-vtable form as a structural slot-index name too, so a real method name at a thunk's address outranks it. The bare `vtable_<i>` form is no longer emitted by any pass and is no longer treated as a slot name. Tests: tests/stages/kuna-itaniumvfunc.xml (off: sub_ names; on: the Drawable thunk is Widget::vfunc_for_Drawable_2 and tail-calls Widget::vfunc_3, and no `::vtable_<i>` appears; the pre-change code fails the four on-pass asserts), tests/cli/elf-function-inventory-vfunc-labels.json, verify_itaniumrtti and engine ranking tests updated. Stages baseline gains the six new assertions. Speed: decompile-all on the fixture 133.6 ms -> 130.5 ms median (noise). Co-Authored-By: Claude Opus 5.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.
What was broken
RE-friction need
pe-function-inventory-labels(round 2, challenge6547b4d50f4238b24302b588,1 instance, severity major). The tester wanted "a trustworthy function inventory for triaging
the PE" and reported:
10 entries on that PE, from
0x140001040(32 B) to0x140001de0(496 B).The filed hypothesis is overturned; the symptom stands
The hypothesis was "public data aliases near code addresses are winning the canonical-name
selection". No data symbol is involved.
<Class>::vftable_<i>is a name kuna synthesises:the MSVC RTTI pass (R3,
analyzers/rtti/mod.rs::emit_vftable_methods) walks each recoveredvftable and emits a
SymFact{Function}at the address each slot points at — the virtualmethod, not the table. All 10 entries are genuine
.textroutines and classifying them asfunctions is correct.
The name is what is wrong, and not merely cosmetically: an MSVC class under multiple
inheritance genuinely owns several vftables, so
<Class>::vftable_<i>collides with thenatural reading "this class's i-th vftable". The need's STOP clause — stop if the fix changes
function DISCOVERY rather than labelling — does not fire: which addresses the pass creates is
untouched.
Mechanism
1. The slot function is named after the function.
<Class>::vftable_<i>→<Class>::vfunc_<i>. Only the table itself keeps avftablename, and it keeps the unindexed<Class>::vftableData label it always had.2. A slot-index name is structural, so a real method name outranks it. The rename alone was
a net regression on one function, and only the whole-corpus sweep found it.
entry_name_rank's tiers are(placeholder, structural, leading-underscore, LENGTH), sobetween a recovered method name and a synthetic slot name the reported name was decided by a
one-character length accident:
0x140002c2cstd::basic_streambuf::showmanyc(30)std::basic_stringbuf::vfunc_5(29)std::basic_streambuf::showmanyc0x140002c32std::basic_streambuf::uflow(27)std::basic_streambuf::uflowstd::basic_streambuf::uflowThe fix is not to pick a longer word. A slot-index name is structural in exactly the sense the
existing
_FINI_<i>tier already documents — it says which slot the function occupies, notwhat the function is called — so
<Class>::vfunc_<i>(MSVC) and<Class>::vtable_<i>(Itanium) now sort into that tier, and a real method name outranks them at any length. They
still beat
sub_/FUN_placeholders, which lose a tier earlier.The acceptance probe now passes
"name": "[^"]*::vftable_[0-9]+"count on the recorded PE: 10 → 0.Promoted to
tests/cli/pe-function-inventory-labels.json, re-pointed off the dataset PE ontothe in-repo
msvc_rtti_x64.exe, which carried the identical defect (Box::vftable_0) — CI hasno dataset. The acceptance is a single
stdout_absentclause, which a deadrttipass wouldalso satisfy, so the promoted probe adds a positive
"name": "Box::vfunc_0"clause and pins--mode aggressiveinstead of relying on auto's 500 KiB threshold to turn the gate on.Sweep
kuna functions --json --mode aggressiveover 19 targets — all 9 in-repo PE fixtures, all 8C++/ELF fixtures including the stripped Itanium-RTTI
.so, thefauxware/aif_gapcontrols,and the recorded dataset PE — plus
kuna decompile-all --jsonover the 9 PE fixtures.::vftable_<i>→::vfunc_<i>: 0.Every changed line anywhere is exactly that one name.
itaniumrtti_x86_64.sois stripped,so its 26
<Class>::vtable_<i>entries only ever facesub_<addr>placeholders, whichalready lose at tier 1. It is carried by unit tests, not by a fixture.
No speed measurement: no pass, decode or analysis step was added or removed. The rtti change is
one format string; the ranking change adds one
rsplit_once+ prefix test per(name, entry)pair inside an inventory sort that already compares those strings.
Gates
make testmake test-stagesmake rust-testmake check-speccheck-spec OKkuna catalog --checkcatalog OK: documents exactly the registered kuna optionspython -m scripts.repipe.clitestskuna-console::engine, 1 inkuna-analysis::rtti,verify_rtti.rsupdatedTooling track: no option, no
phases.tomlrow, no catalog counter, notests/stagescase — sono counter or file lease was taken.
Left for a follow-up (recorded in the need)
The MSVC pass has no defining-class attribution, so a slot shared by a base and its derivatives
is named once per class and the canonical pick among them is arbitrary
(
std::bad_alloc::vfunc_0canonical overstd::exception::vfunc_0on lexicographic orderalone). The Itanium sibling already attributes an inherited slot to the class that defines
it. The Itanium pass's own
vtable_<i>stem carries the same naming defect and was left alonedeliberately: renaming it edits the
itaniumrttirow inphases.toml, which is leased toanother builder this round.
🤖 Generated with Claude Code