Description:
When running mtr test suite, I get a crash on mysql shutdown from tiem to time.
The access violation is in ntdll.dll and comes from EnterCriticalSection within pthread_cond_timedwait. It suggests that CRITICAL_SECTION is invalid (maybe already destroyed)?
the callstacks at the moment of the crash
Crashing thread (handle manager):
ntdll.dll!_RtlpWaitOnCriticalSection@8() + 0x99 bytes
ntdll.dll!_RtlEnterCriticalSection@4() + 0x168e8 bytes
> mysqld.exe!pthread_cond_timedwait(pthread_cond_t * cond=0x0181c374, _RTL_CRITICAL_SECTION * mutex=0x0181c358, timespec * abstime=0x02fafc24) Line 127 C
mysqld.exe!handle_manager(void * arg=0x00000000) Line 90 + 0x14 bytes C++
mysqld.exe!pthread_start(void * param=0x00e03ab0) Line 85 + 0x3 bytes C
mysqld.exe!_callthreadstart() Line 293 + 0x6 bytes C
mysqld.exe!_threadstart(void * ptd=0x00e295a0) Line 275 + 0x5 bytes C
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes
Main thread:
kernel32.dll!_WaitForMultipleObjects@16() + 0x18 bytes
mysqld.exe!pthread_cond_timedwait(pthread_cond_t * cond=0x0182bba0, _RTL_CRITICAL_SECTION * mutex=0x0182bb40, timespec * abstime=0x002df74c) Line 126 C
> mysqld.exe!my_thread_global_end() Line 180 + 0x14 bytes C
mysqld.exe!my_end(int infoflag=0) Line 236 C
mysqld.exe!win_main(int argc=10, char * * argv=0x00ac3638) Line 4529 + 0x14 bytes C++
mysqld.exe!mysql_service(void * p=0x00000000) Line 4549 + 0x12 bytes C++
mysqld.exe!main(int argc=10, char * * argv=0x00ac3638) Line 4735 + 0x13 bytes C++
The code around the crash:
pthread_cond_timedwait():
result= WaitForMultipleObjects(2, cond->events, FALSE, timeout);
EnterCriticalSection(&cond->lock_waiting); // <--Crash here
cond->waiting--;
The caller of the function handle manager() stucks here:
while ((!error || error == EINTR) && !abort_manager)
error= pthread_cond_timedwait(&COND_manager, &LOCK_manager, &abstime);
Another thread (main) is in the
while (THR_thread_count > 0)
loop in my_thread_global_end()
How to repeat:
switch on Windows Error reporting or Visual Sttudio JIT debugger,
run mtr many times.