3885 – No multithread support for Windows DLL

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3885 - No multithread support for Windows DLL
Summary: No multithread support for Windows DLL
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: Sean Kelly
URL:
Keywords:
Depends on:
Blocks:
Reported: 2010年03月06日 08:16 UTC by Rainer Schuetze
Modified: 2015年06月09日 05:14 UTC (History)
2 users (show)

See Also:


Attachments
dll test project (2.83 KB, application/octet-stream)
2010年03月06日 08:16 UTC, Rainer Schuetze
Details
allow multithreading with dlls (22.56 KB, patch)
2010年03月06日 08:31 UTC, Rainer Schuetze
Details | Diff
allow multithreading with dlls in D1 (11.17 KB, patch)
2010年03月06日 08:35 UTC, Rainer Schuetze
Details | Diff
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Schuetze 2010年03月06日 08:16:32 UTC
Created attachment 583 [details] 
dll test project
There is currently no support for multithreading when creating DLLs. Here's a
small test project that creates a DLL and builds three programs:
test.exe: links against the import library of the DLL
testdyn.exe: loads the DLL via LoadLibrary
teststat.exe: links evreything without using DLLs (just for comparison).
The test program creates 10 threads (in the case of testdyn.exe 5 before
loading the library), and then calls a few functions mainly testing TLS access
and memory corruption.
This is for both D1 and D2, see the top of build.bat for DMD path and switching
versions.
Both test.exe and testdyn.exe produce access violations.
Comment 1 Rainer Schuetze 2010年03月06日 08:31:23 UTC
Created attachment 584 [details] 
allow multithreading with dlls
Here's a patch that fixes the issue for D2. It consists of 3 parts:
1. some modifications to core.thread to allow attaching and detaching to threads that are not the current thread.
2. a support file core.thread_helper to enumerate running threads, so that you can attach to these in DllMain
3. another support file core.dll_helper to fix the missing implicite TLS support on Windows XP.
After applying the patch to druntime, the test project can be compiled with -version=use_patch to test it.
Sorry, don't know enough for the Posix version, so there might be some issues to sort out.
Comment 2 Rainer Schuetze 2010年03月06日 08:35:50 UTC
Created attachment 585 [details] 
allow multithreading with dlls in D1
this is a similar patch for D1:
1. some adjustments to std.thread to attach and detach threads.
2. the same thread_helper file, but with different module name and import.
Comment 3 Walter Bright 2010年03月12日 00:46:16 UTC
I've got these integrated in to Phobos and checked in now. Everyone who needs this, please give it a try!
Comment 4 Don 2010年04月09日 19:12:47 UTC
Fixed DMD1.058 and DMD2.042.


AltStyle によって変換されたページ (->オリジナル) /