DynamoRIO / DynamoRIO/dynamorio

atomic_ operations not safe from compiler optimizations

Open
#3,352 0 comments 0 reactions 0 assignees View on GitHub
Bug-AppFail Bug-Hang OpSys-x64 OpSys-x86
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

I don't have/know of any test or app that exposes this. In particular, looking at objdump currently - at least on my machine - the compiler doesn't take advantage of the hole. Currently, we C-code

ATOMIC_OP (e.g. inc, compare/exchange etc.)
SET (flag operation)

Both statements are "asm volatile". Theoretically, the compiler is allowed to move flag modifying instructions in between the statements. To fix, we need to either

* move all instructions into the same asm volatile statement
OR
* at least add "cc" clobber to both asm volatile statements (and I would add "memory" to both as well).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.