mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 10:00:16 +02:00
There were two bugs in here. The first bug here is with with the CMPXCHG emulation. 1) If the *Expected* value did *NOT* match what was in memory 2) *AND* The *Desired* value matched the memory value 3) The CAS would incorrectly return success for this CMPXCHG 4) Thus setting ZF incorrectly The second bug comes from atomic memory operations (Add, CLR, EOR, SET, SWAP). This operation is a Load + <Op> + CAS 1) If the memory backing between the Load and CAS changes 2) The CAS would then fail 3) On Atomic memory operations this should then retry to ensure it completes successfully 4) We were not retrying on failure in this case 5) Thus something like `LOCK INC` would have never atomically incremented correctly 6) We can't use our ASM unit tests to test this, since it needs thread contention.