• Davi Arnaut's avatar
    Bug#52419: x86 assembly based atomic CAS causes test failures · be348787
    Davi Arnaut authored
    The problem was that the x86 assembly based atomic CAS
    (compare and swap) implementation could copy the wrong
    value to the ebx register, where the cmpxchg8b expects
    to see part of the "comparand" value. Since the original
    value in the ebx register is saved in the stack (that is,
    the push instruction causes the stack pointer to change),
    a wrong offset could be used if the compiler decides to
    put the source of the comparand value in the stack.
    
    The solution is to copy the comparand value directly from
    memory. Since the comparand value is 64-bits wide, it is
    copied in two steps over to the ebx and ecx registers.
    be348787
x86-gcc.h 5.64 KB