Importance of alignment even on x86 machines, part 2
The various Interlocked functions
(InterlockedIncrement, and so on)
require that the variable being updated be properly aligned,
even on x86, a platform where the CPU silently fixes unaligned
memory access invisibly.
If you pass an unaligned pointer to one of the Interlocked
functions, the operation will still succeed, but the result
won't be atomic. Another processor may see a partially-completed
update.
This is a particularly insidious bug since it happens only
on multiprocessor machines under very tight timing conditions.
You will be hard-pressed to reproduce this in the laboratory.
(A commenter
stole my thunder and remarked on it yesterday.)
Moral of the story: Same as yesterday. Mind your alignment.