Repository navigation
Conversation
heartpunk
marked this pull request as ready for review
November 22, 2026 02:52
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.
When a 32-bit
CMPXCHGcompares against memory successfully, VEX incorrectly clears the upper half of the RAX register. This can cause angr to analyze an instruction using the wrong register value. This change preserves RAX on success while keeping the correct value on failure, with and without theLOCKprefix. We reproduced the error with tests of both outcomes: the two success cases failed before the fix, and all four cases passed afterward.Details
For example, with
RAX = 0x1234567811223344and memory containing0x11223344, the old lift incorrectly producesRAX = 0x0000000011223344on success. The failure path still zero-extends the 32-bit memory value into RAX.The Intel and AMD instruction entries assign the source to memory on equality and write the old memory value to EAX on inequality. Their register rules specify that a 32-bit GPR write zero-extends to 64 bits. Intel SDM Vol. 2A, CMPXCHG, Operation, p. 3-194 · Intel SDM Vol. 1, §3.4.1.1, p. 3-13 · AMD APM Vol. 3, CMPXCHG, p. 167 · AMD APM Vol. 1, §3.4.5, p. 74.
T.J. Purtell proposed preserving the full accumulator in both memory paths in 2011. The 2024 angr/VEX fix covered the register operand. Valgrind bug 275024 · Purtell’s original patch · angr/vex#63.
The regression lives in the PyVEX suite. Its two cases check the zero-flag condition and trace both inputs to the accumulator write in the lifted IR for locked and unlocked memory operands. Both failed with the old VEX pin (
fd41c67), and the complete PyVEX suite passed 92/92 with the fix. Companion regression in angr/pyvex#610.Separately, local concrete execution through angr 10.0.7 checked RAX, memory, and ZF for both 32-bit memory forms on both outcomes. Only the two successes failed on the parent. All four passed with the fix. A broader check of locked 8-, 16-, 32-, and 64-bit memory operands, unlocked 32-bit memory, and a 32-bit register operand also passed all 12 cases with the fix.
The functional fix was already present in
be99aa9. A Codex subagent (gpt-6.2-astra, high reasoning effort) clarified the source comment, implemented the regression, and ran the tests reported above. A separate Codex subagent (gpt-6.2-astra, max reasoning effort) independently reviewed the VEX change.