DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.57k stars 552 forks source link

i#3544 RV64: Fix patch_stub for unaligned stub_pc #6711

Closed ksco closed 3 months ago

ksco commented 3 months ago

To simplify codegen, we require the exit stub pc to be aligned to 4 bytes. If it is not aligned, we place a 2-byte c.nop at the beginning of the exit stub. Therefore, all functions that modify the exit stub should skip the possible c.nop.

The wrongly implemented patch_stub() makes unlink_branch() not affect the exit stub, which makes the async signal handling error-prone.

Before the fix, it hits the following assertion ~1/5 times when running linux.signal0001 on a RISC-V machine, which indicates that the second signal comes from a different fragment after the unlinking, and the real reason is that the unlinking is not successful.

ASSERT signal.c:4954 info->interrupted == NULL || info->interrupted == f

It would be great if we could enable the signal tests in CI, but these tests do not work in QEMU for unknown reasons.

Issue: #3544 Related: #2328