Skip to content

Fix disassembler silent truncation - #14136

Draft
jlb6740 wants to merge 2 commits into
bytecodealliance:mainfrom
jlb6740:fix-disassembler-silent-truncation
Draft

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

Conversation

@jlb6740

@jlb6740 jlb6740 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

No description provided.

`CompiledCodeBase::disassemble` hands each block to capstone's
`disasm_all`, which stops at the first instruction it cannot decode and
returns the instructions decoded so far rather than an error. Nothing
compared the bytes consumed against the length of the block, so that
instruction and everything after it simply disappeared from the listing.

This matters most for `precise-output` filetests: the truncated output is
blessed into the expectation, and the test then passes while asserting
nothing at all about those bytes. An encoding bug in an instruction that
capstone does not understand would be invisible.

It is easy to hit today. The bundled capstone cannot decode AVX-VNNI, so a
function containing `vpdpbusd` lost five instructions, the entire epilogue
included, leaving only:

    ; block1: ; offset 0x4
    ;   movdqa %xmm0, %xmm5
    ;   movdqa %xmm2, %xmm0

Print the remaining bytes as `.byte` directives, carrying over relocation
and trap annotations so those are not dropped either. This is the form
capstone itself emits for undecodable s390x instructions, where the
instruction length is encoded in the first two bits and it can therefore
resynchronize. x86 instruction length cannot be determined without
decoding, so there is no way to resynchronize and the whole tail of the
block is covered by the dump.

The updated expectations are purely additive; no existing disassembly line
changes. Those blocks end in constant pool data, which capstone already
rendered as meaningless instructions such as `addb %al, (%rax)` before
giving up partway through.
@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
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