Skip to content

Fix disassembler silent truncation - #14136

Open
jlb6740 wants to merge 1 commit into
bytecodealliance:mainfrom
jlb6740:fix-disassembler-silent-truncation
Open

Fix disassembler silent truncation#14136
jlb6740 wants to merge 1 commit into
bytecodealliance:mainfrom
jlb6740:fix-disassembler-silent-truncation

Conversation

@jlb6740

@jlb6740 jlb6740 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Capstone's disasm_all stops at the first instruction it can't decode and
returns success with whatever it managed to decode. We never compared that
against the block length, so that instruction and everything after it
vanished from the listing. For precise-output filetests the truncated
output gets blessed, and the test then passes without asserting anything
about those bytes.

This is reachable today: the bundled capstone can't decode AVX-VNNI, so a
function containing vpdpbusd was silently dropping five instructions.
It is also a precursor to the APX work, whose EVEX map 4 encodings hit the
same path; those filetests were being blessed as truncated output and so
verified nothing about the instructions they were added to cover.

Print the leftover bytes as .byte, keeping the reloc and trap
annotations. s390x expectations already look like this. Resyncing after
the bad instruction isn't possible on x86 without knowing its length, and
guessing yields plausible but wrong instructions.

The updated expectations only gain lines; nothing already printed changed.
Those blocks end in constant pool data that capstone was already rendering
as nonsense.

@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. labels Aug 14, 2026
@jlb6740
jlb6740 force-pushed the fix-disassembler-silent-truncation branch 2 times, most recently from d6d7be5 to fd88312 Compare August 20, 2026 01:24
@jlb6740
jlb6740 marked this pull request as ready for review August 20, 2026 01:26
@jlb6740
jlb6740 requested a review from a team as a code owner August 20, 2026 01:26
@jlb6740
jlb6740 requested review from fitzgen and removed request for a team August 20, 2026 01:26
Capstone's `disasm_all` stops at the first instruction it can't decode and
returns success with whatever it managed to decode. We never compared that
against the block length, so that instruction and everything after it
vanished from the listing. For `precise-output` filetests the truncated
output gets blessed, and the test then passes without asserting anything
about those bytes.

This is reachable today: the bundled capstone can't decode AVX-VNNI, so a
function containing `vpdpbusd` was silently dropping five instructions.
It is also a precursor to the APX work, whose EVEX map 4 encodings hit the
same path; those filetests were being blessed as truncated output and so
verified nothing about the instructions they were added to cover.

Print the leftover bytes as `.byte`, keeping the reloc and trap
annotations. s390x expectations already look like this. Resyncing after
the bad instruction isn't possible on x86 without knowing its length, and
guessing yields plausible but wrong instructions.

The updated expectations only gain lines; nothing already printed changed.
Those blocks end in constant pool data that capstone was already rendering
as nonsense.

prtest:full
@jlb6740
jlb6740 force-pushed the fix-disassembler-silent-truncation branch from fd88312 to 32c6a59 Compare August 21, 2026 23:30
@jlb6740 jlb6740 mentioned this pull request Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant