Skip to content

fix(type_match): credit arguments for code-only decompilers (fixes wcomment=0) - #28

Merged
mahaloz merged 1 commit into
mainfrom
fix/type-match-code-only-args
Jul 22, 2026
Merged

mahaloz merged 1 commit into
mainfrom
fix/type-match-code-only-args

Conversation

@mahaloz

@mahaloz mahaloz commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

bash/O0/mksyntax::wcomment — void wcomment(FILE *fp, int c) — scored type_match 0.0 for codex despite it recovering both argument types exactly.

Root cause: the type_match metric matches structured variables in 3 passes, where Pass 1 matches arguments by ABI position (name-independent). But decompilers that emit only C text with no structured variables — codex, claude-code, dewolf, r2dec — fell to a regex fallback that (1) parsed only type name; declarations, never signature arguments, and (2) matched by name only. A function whose only variables are its arguments therefore scored 0 for all four.

Fix

When a decompiled function exposes no structured variables, parse its C — the signature into arguments (with ABI arg_index) + local declarations — and route through the existing _match_structured. Arguments get the same name-independent position credit every structured decompiler already gets. cache_version 3 → 4.

Effect (sample-set, shared denominator 229)

decompiler type_match perfect
codex 0 → 27 now ahead of structured
claude-code 0 → 22
dewolf, r2dec also rise (were zeroed the same way)
ida / ghidra / angr 8 / 12 / 13 unchanged

Monotonic by construction (denominator fixed at len(GT vars), only adds argument TPs). Decompilers exposing real variables skip the new path and are provably unchanged (overlay entries byte-identical to the pre-change backup).

Scope

Only decbench/metrics/type_match.py + tests + a recompute helper. Does not touch site/ or the in-flight aggregate.py normalize fix — the site should be rebuilt after both land. scripts/refresh_typematch_codeonly.py refreshes the overlay for only the four code-only decompilers.

Tests: added test_code_parsed_arguments_by_position; 21 type-match tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y1FDD4KNcekjU4LJQHHYbo

…omment=0)

Decompilers that emit only C text with no structured `variables` (the LLM
backends codex/claude-code, plus dewolf and r2dec) were scored by a regex
fallback that (1) parsed only `type name;` declarations — never function-
signature ARGUMENTS — and (2) matched by name only. So a function whose only
variables are its arguments scored 0 even with perfect argument types, e.g.
`bash/O0/mksyntax::wcomment` (`void wcomment(FILE *fp, int c)`): codex recovered
both argument types exactly and still got type_match 0.0.

Fix: when a decompiled function exposes no structured variables, parse its C —
the function signature into arguments (with ABI `arg_index`) plus local
declarations — and route through the existing `_match_structured` matcher, so
arguments get the same name-independent ABI-position credit every structured
decompiler already gets (Pass 1). Bumped cache_version 3 -> 4.

Effect (sample-set, shared denominator 229): codex 0 -> 27 perfect, claude-code
0 -> 22 (now ahead of ida 8 / ghidra 12 / angr 13); dewolf and r2dec also rise.
The change is monotonic — the denominator is fixed at len(GT vars) and it only
adds argument true-positives, so no score can fall. Decompilers exposing real
`variables` (angr/ghidra/ida/binja/kuna/phoenix) skip the new path entirely and
are unchanged.

scripts/refresh_typematch_codeonly.py recomputes type_match for ONLY the four
code-only decompilers and merges into the published type_match_new.json overlay,
leaving structured decompilers' entries byte-identical (verified).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1FDD4KNcekjU4LJQHHYbo
@mahaloz
mahaloz merged commit f60fcb0 into main Jul 22, 2026
@mahaloz
mahaloz deleted the fix/type-match-code-only-args branch July 22, 2026 17:53
mahaloz added a commit that referenced this pull request Jul 22, 2026
Rebuilds the published site on top of both landed fixes:
- type_match now credits arguments for code-only decompilers (#28): codex/
  claude-code type_match on the sample-set jump from ~0 to 27/229 and 22/229
  perfect (ahead of ida 8 / ghidra 12); dewolf/r2dec also rise. Structured
  decompilers are unchanged.
- the normalize toggle no longer collapses when sample-set-only LLM decompilers
  are present.

No malware source ships in samples.json (is_malware projects excluded).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1FDD4KNcekjU4LJQHHYbo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant