Fix disassembler silent truncation - #14136
Draft
jlb6740 wants to merge 2 commits into
Draft
Conversation
`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.
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.
No description provided.