digitalmars.D.bugs - [Issue 20430] New: [Regression 2.089.0] DLL Runtime.terminate() hangs
- d-bugmail puremagic.com (127/127) Dec 04 2019 https://issues.dlang.org/show_bug.cgi?id=20430
https://issues.dlang.org/show_bug.cgi?id=20430 Issue ID: 20430 Summary: [Regression 2.089.0] DLL Runtime.terminate() hangs Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: regression Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: radu.racariu gmail.com The following program and dll will hang when build with 2.089.0 and will work on older versions: dll.d ` module dll; import core.sys.windows.windows; import core.stdc.stdio : printf; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { import core.runtime : Runtime; switch (ulReason) { case DLL_PROCESS_ATTACH: printf("DLL_PROCESS_ATTACH\n"); Runtime.initialize(); break; case DLL_PROCESS_DETACH: printf("DLL_PROCESS_DETACH\n"); Runtime.terminate(); printf("Terminated!\n"); break; case DLL_THREAD_ATTACH: printf("DLL_THREAD_ATTACH\n"); return false; case DLL_THREAD_DETACH: printf("DLL_THREAD_DETACH\n"); return false; default: } return true; } /// DLL entry point export extern (C) void extInit() { printf("Called `extInit` from the DLL\n"); } ` program.d ` module program import core.runtime; import core.stdc.stdio; import core.sys.windows.windows; void load() { string dll = "bug.dll"; HMODULE handle; FARPROC fp; printf("Start Dynamic Link...\n"); handle = cast(HMODULE) Runtime.loadLibrary(dll); if (handle is null) { printf("error loading %.*s\n", dll.length, dll.ptr); return; } // bind the extInit function fp = GetProcAddress(handle, "extInit"); if (fp is null) { printf("error loading symbol extInit()\n"); return; } extInit = cast(ExtInitFunc) fp; } /// Ext register entry point alias ExtInitFunc = void function(); ExtInitFunc extInit; int main() { printf("Start loading.\n"); load(); printf("End...\n"); return 0; } ` Working output (2.088.1) ` Start loading. Start Dynamic Link... DLL_PROCESS_ATTACH End... DLL_PROCESS_DETACH Terminated! ` Bad output (2.089.0) ` End... DLL_THREAD_ATTACH DLL_THREAD_DETACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_ATTACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_THREAD_ATTACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_THREAD_DETACH DLL_PROCESS_DETACH ` --
Dec 04 2019