http://bugs.winehq.org/show_bug.cgi?id=24185
Summary: Deadlock in vectored exception handling Product: Wine Version: 1.3.0 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: krissn@op.pl
When running MapSource (a Garmin GPS map manager) I noticed that the application will hang soon after starting. The hang occurs at random time when MapSource is drawing the map on the screen. The log output clearly indicates a classic deadlock:
err:ntdll:RtlpWaitForCriticalSection section 0x7efec6e0 "/var/tmp/portage/app-emulation/wine-1.3.0/work/wine-1.3.0/dlls/ntdll/exception.c: vectored_handlers_section" wait timed out in thread 001b, blocked by 0009, retrying (60 sec) err:ntdll:RtlpWaitForCriticalSection section 0x7e9f3d80 "/var/tmp/portage/app-emulation/wine-1.3.0/work/wine-1.3.0/dlls/gdi32/gdiobj.c: gdi_section" wait timed out in thread 0009, blocked by 001b, retrying (60 sec)
Some deeper investigation revealed that the GDI's DIB exception handler is involved in this problem. Here's the scenario:
1. Thread A calls a GDI function. The function takes the "gdi_section". 2. Thread B raises an exception (could be a C++ exception). The call_vectored_handlers() function is called to call the handlers. The "vectored_handlers_section" is entered. 3. Thread B execues the X11DRV_DIB_FaultHandler(), which eventually leads to a call to GetObjectW() and in turn GDI_GetObjPtr(). The last one blocks on "gdi_section". 4. Thread A throws an Access Violation exception in the DIB functions. The call_vectored_handlers() function is called, but this time it blocks on "vectored_handlers_section"
A possible solution would be to replace the "vectored_handlers_section" by a RW lock. This would ensure that multiple exception handlers are called simultaneously while still maintaining consistency in case the vectored exception handler list needs to be changed.