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.
http://bugs.winehq.org/show_bug.cgi?id=33331
--- Comment #1 from Dmitry Timoshkov dmitry@baikal.ru 2013-04-04 03:42:04 CDT --- Created attachment 44084 --> http://bugs.winehq.org/attachment.cgi?id=44084 Windows 7 output
http://bugs.winehq.org/show_bug.cgi?id=33331
--- Comment #2 from Dmitry Timoshkov dmitry@baikal.ru 2013-04-04 03:43:02 CDT --- Created attachment 44085 --> http://bugs.winehq.org/attachment.cgi?id=44085 Wine output
http://bugs.winehq.org/show_bug.cgi?id=33331
--- Comment #3 from Rico kgbricola@web.de 2013-04-04 04:01:54 CDT --- A somewhat similar problem is bug 32951 .
Thus it seems, that all threads beside the main tread should be terminated first, regardless where the thread originates from. Then all resources could be unloaded.
http://bugs.winehq.org/show_bug.cgi?id=33331
--- Comment #4 from Dmitry Timoshkov dmitry@baikal.ru 2013-04-04 10:10:48 CDT --- (In reply to comment #3)
A somewhat similar problem is bug 32951 .
Thus it seems, that all threads beside the main tread should be terminated first, regardless where the thread originates from. Then all resources could be unloaded.
When a process terminates freeing resources doesn't make sense and is pure waste of time since the process address space is going to be destroyed.
What libiomp5md.dll does and what is the source of this bug report doesn't make sense either, but since it works under Windows and real world application depends on this then Wine needs to be fixed.
http://bugs.winehq.org/show_bug.cgi?id=33331
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |austinenglish@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=33331
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |bfcdf6df8eea1230fb0e1835a80 | |9e49e5971e5d2 Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #5 from Dmitry Timoshkov dmitry@baikal.ru 2013-05-17 20:28:00 CDT --- Should be fixed now.
http://bugs.winehq.org/show_bug.cgi?id=33331
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #6 from Alexandre Julliard julliard@winehq.org 2013-05-24 13:33:25 CDT --- Closing bugs fixed in 1.5.31.
https://bugs.winehq.org/show_bug.cgi?id=33331
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |focht@gmx.net Component|-unknown |kernel32