Repository navigation
[AUTOMATED] feat(analysis): libctypes on by default - #658
Merged
Merged
Conversation
The named libc/POSIX aggregate pointers in the built-in prototype tables (FILE *, stat *, dirent *, option *, ...) shipped behind a default-off gate. Flip the default to `opaque`: the gate's unset-env case and `reset_defaults_internal` both move, mirroring the sibling `dwarfstructs` bridge (only an explicit off-token disables). `--option libctypes off` still restores the shipped `void *` tables - verified byte-identical to a binary built from main over eight whole binaries. Two expectations in the tree pinned the old spelling and move with it: the phase-catalog byte fixture (the row's `default`), and the ghidra-sim faillog line pin, where one `void *` doing two jobs in that fixture's main splits into `passwd *` and `FILE *`. The evidence for the default - typesweep over 444 slices, the whole-binary hunk classification, the stage-corpus replay - is in docs/features/libctypes/flip.md and record.json. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…lock Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…inaries) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…env bridge The two kuna-cli bridges kept the on-token polarity from when the option was default-off, so any token that is not `opaque`/`on`/`1`/`true` mapped to `off` — the opposite of the gate reader and of the sibling dwarfstructs and typedepth bridges. Unreachable today (the value validator rejects anything but off|opaque) but it is the site a later layout value would trip. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
… sweep moves The spec paragraph and the catalog's use_when overstated the flip in three places the feature's own record already contradicted: one function does score worse, the sweep does move numeric literals (a constant offset is absorbed into the field name it selects) and it does change control flow in three PLT thunks that gain a return, and the stage corpus is not blind to the row — tests/stages/kuna-libctypes.xml pins it in both arms. The export's +58 cc errors are split 51 shells / 7 name clash, not "all from that". Adds the missing by-value row to flip.md: named aggregate LOCALS 0 -> 88 over the nine sweep binaries, with gzip 0xea40's st_atim/st_mtim offsets as proof the collapse lands exactly, and the scanner that counts them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
… datatests The gate note read as if every XML corpus were blind to the row. Only the 675 datatests are: 16 of the 217 stage fixtures load a file and one of them pins this option in both arms. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…, not by one example 58 of the 88 named by-value locals are read back through vN._off_size_, and none of those reads lands past the shell's declared size — the check that the offsets were preserved rather than reinterpreted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
… default plan.md and analysis.md still describe the option as it shipped (default off); say so at the top so neither reads as the current default. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
…e final tip Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…n the census `libctypes` is default-on since #658 and types a `FILE *` parameter with a named composite, so `kind == struct` alone counted 289 parameters structsynth never touched. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…e rebase `libctypes` is on by default since #658 and names the nine `FILE *` parameters the earlier census counted, so every number the proposal turns on moves: - false-positive census 301 -> 292, `_IO_FILE` 9 -> 0, one ordinary false positive unchanged (`ls` `strmode`) - layout precision 762/846 = 0.901 -> 704/787 = 0.894; the nine carried 59 claimed fields of which 58 matched, so declining them costs 0.006 - `type_match` 1760.25 -> 1759.34 on the raised baseline, same four rows - TRex Fig.6 and IsCStruct re-run rather than quoted from the first round: up on all eight binaries, +109 net, `ls` O2 the one regression Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…references of a pointer parameter (structsynth) A new P5 action (`p5_types/kuna_structsynth.rs`) collects the constant-offset loads and stores made through a pointer parameter, prunes them to a layout a C compiler reproduces byte for byte, and type-locks the parameter to the synthesized `struct_N *`. Behind `--option structsynth off|param`. Rebased onto origin/main (foldcallretphi #654, ptrfromuse #659, libctypes default-on #658); counters re-derived on the rebased tree. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…references of a pointer parameter (structsynth) A new P5 action (`p5_types/kuna_structsynth.rs`) collects the constant-offset loads and stores made through a pointer parameter, prunes them to a layout a C compiler reproduces byte for byte, and type-locks the parameter to the synthesized `struct_N *`. Behind `--option structsynth off|param`. Rebased onto origin/main (foldcallretphi #654, ptrfromuse #659, libctypes default-on #658); counters re-derived on the rebased tree. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…references of a pointer parameter (structsynth) A new P5 action (`p5_types/kuna_structsynth.rs`) collects the constant-offset loads and stores made through a pointer parameter, prunes them to a layout a C compiler reproduces byte for byte, and type-locks the parameter to the synthesized `struct_N *`. Behind `--option structsynth off|param`. Rebased onto origin/main (foldcallretphi #654, ptrfromuse #659, libctypes default-on #658); counters re-derived on the rebased tree. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz
added a commit
that referenced
this pull request
Sep 17, 2026
…references of a pointer parameter (structsynth) A new P5 action (`p5_types/kuna_structsynth.rs`) collects the constant-offset loads and stores made through a pointer parameter, prunes them to a layout a C compiler reproduces byte for byte, and type-locks the parameter to the synthesized `struct_N *`. Behind `--option structsynth off|param`. Rebased onto origin/main (foldcallretphi #654, ptrfromuse #659, libctypes default-on #658); counters re-derived on the rebased tree. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
A parameter that a libc function's own declaration names — a
FILE *, astat *, adirent *— comes out asvoid *orlongunless you know to askfor it. On a fixture in this repo:
a0goes tofreadandfcloseand nowhere else. The table already knows whatthat is —
int fclose(FILE *)is a declaration, not an inference — and says sounder
--option libctypes opaque, which this makes the default:void * sub_1249(FILE *a0).The fix
libctypesdefaults toopaque: the gate's unset-env case andreset_defaults_internalboth move, mirroring the siblingdwarfstructsbridge (only an explicit off-token disables).
--option libctypes offstill restores the shippedvoid *tables, verifiedbyte-identical to a binary built from
mainover nine whole binaries.tests/stages/kuna-libctypes.xmlnow restoresopaque, notoff, in its lastcommand — the gate is a process environment variable and the stage corpus runs
in one process, so the old restore would have disabled the table for every test
after it.
kuna-clienv bridges pass the option's token through rather thanmatching on-tokens, so they agree with the gate reader and with the
dwarfstructs/typedepthsiblings. Inert today — the value validator rejectsanything but
off|opaque— but it is the site a later layout value would trip.phase-catalog byte fixture (that row's
default), and the ghidra-sim faillogline count, where one
void *doing two jobs infaillog'smain— thegetpwentresult and the streamferror/fflushtakes — splits intopasswd *andFILE *.The tests
make test675/675 PARITY OK — but 0 of 83 datatests open a file, so that corpuscannot see this tier either way.
make test-stages1038/1038 PARITY OK and are-recorded baseline byte-identical to the tree's: no assertion moved, and
replaying all 16
load filefixtures in both arms leaves 15 byte-identical.make test-cli178/178, withchanging-namestyle-invalidates-discoverednowpinning
sub_1249(FILE *param_1)— that parameter goes tofreadandfcloseand nothing else, and
param_1rather thana0is still what proves the namingstyle applied.
decbench
type_match, 444 slices / 10,748 functions: perfect 889 → 959, 720improved, 0 moved off perfect, 1 worsened. Whole-binary
decompile-allover4,301 functions: none lost or gained, call targets identical in every one,
PTRSUB(0 in both arms. Declarations go down 17,183 → 17,039 and pieceaccessors (
vN._off_size_) up 1,017 → 1,275: astat *argument names theon-stack object the call fills, so 88 scattered slots collapse into the
aggregate they were (offsets verified exact). Worst interleaved min-of-15 speed
delta +1.64% against a 5% budget. Every number, the one worsened function and
the costs included, is in
docs/features/libctypes/flip.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29