We use SQLite library in our product and suddenly after recompilation with different compiler version (Visual C++) it started crashing on customer computers.
The crash is
ExceptionAddress: 0710eadd (sqlite3!sqlite3_transfer_bindings+0x0004e5bd)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: 07148688
Attempt to write to address 07148688
and the code causing the crash is the following (part of sqlite3MutexInit):
0710ead0 b804811407 mov eax, 0x07148104
0710ead5 b97c861407 mov ecx, 0x0714867c
0710eada 0f44c8 cmove ecx, eax
0710eadd f30f7e410c movq xmm0, mmword ptr [ecx+0Ch]
The corresponding C code:
if( sqlite3GlobalConfig.bCoreMutex ){
pFrom = sqlite3DefaultMutex();
}else{
pFrom = sqlite3NoopMutex();
}
memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc));
It is not particularly important, but in our case sqlite3GlobalConfig.bCoreMutex is set to 1.
The problem is that in this particular case the memory at address 07148688 is readable and the instruction is supposed to read it, not write it.
We have memory dumps from two machines and in both cases it happened on Athlon XP processors (Family/Model/Stepping: 6/10/0, 6/8/1).
Recompilation with several Visual C++ versions (2012, 2013 and 2013 Update 1) yeilds slightly different code (movq vs movdqu instruction at the faulting address), but the crash happens consistently.
Could it be caused by processor or compiler bug we are hitting?