http://bugs.winehq.org/show_bug.cgi?id=33331
Bug #: 33331 Summary: When DLL receives PROCESS_DETACH notification when a process is exiting all the threads should be already terminated Product: Wine Version: 1.5.27 Platform: x86-64 OS/Version: Linux Status: NEW Keywords: download, source, testcase Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: dmitry@baikal.ru Classification: Unclassified
Created attachment 44083 --> http://bugs.winehq.org/attachment.cgi?id=44083 source and binary for the test
While debugging the problem described in http://www.winehq.org/pipermail/wine-patches/2013-March/123127.html (libiomp5md.dll waits until all the tracked threads terminate and doesn't return control out of its PROCESS_DETACH handler when process is going to exit) I decided to create a test which examines what's supposed to happen when static (loaded implicitly as a part of PE imports) and dynamic (loaded explicitly by LoadLibrary) DLLs create threads along with threads created by main exe.
To make long story short: main difference between Windows and Wine is that Wine doesn't terminate threads before calling PROCESS_DETACH for each loaded DLL.
Here are the snippets from results I see under Windows 7 (both 32 and 64 bit builds behave same way) and Wine:
Win7: ... main: call ExitProcess(0) dynamic: 72FB0000, DLL_PROCESS_DETACH, 00000001 dynamic: GetExitCodeThread(0) => 1,0 dynamic: GetExitCodeThread(1) => 1,0 dynamic: GetExitCodeThread(2) => 1,0 static: 72FC0000, DLL_PROCESS_DETACH, 00000001 static: GetExitCodeThread(0) => 1,0 static: GetExitCodeThread(1) => 1,0 static: GetExitCodeThread(2) => 1,0 ===================================================== Wine: ... main: call ExitProcess(0) dynamic: 00330000, DLL_PROCESS_DETACH, 00000001 dynamic: GetExitCodeThread(0) => 1,259 dynamic: GetExitCodeThread(1) => 1,259 dynamic: GetExitCodeThread(2) => 1,259 static: 10000000, DLL_PROCESS_DETACH, 00000001 static: GetExitCodeThread(0) => 1,259 static: GetExitCodeThread(1) => 1,259 static: GetExitCodeThread(2) => 1,259
I.e. libiomp5md.dll when it receives PROCESS_DETACH notification at process exit time shoudn't get STILL_ACTIVE (259) return value from GetExitCodeThread.