[Issue 4996] New: When D's dll unloaded, writeln(stdout) doesn't work well.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 5 09:31:27 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4996

           Summary: When D's dll unloaded, writeln(stdout) doesn't work
                    well.
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean at invisibleduck.org
        ReportedBy: zan77137 at nifty.com


--- Comment #0 from SHOO <zan77137 at nifty.com> 2010-10-05 09:31:02 PDT ---
When D's dll unloaded, writeln(stdout) doesn't work well.
I guess that druntime's dll termination was failure.
Or, my miss. Do you understand this cause?

---------------- dll.d -------------------------
import std.c.windows.windows;
import core.dll_helper;

__gshared HINSTANCE g_hInst;

extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
{
    switch (ulReason)
    {
    case DLL_PROCESS_ATTACH:
        g_hInst = hInstance;
        dll_process_attach( hInstance, true );
        break;

    case DLL_PROCESS_DETACH:
        dll_process_detach( hInstance, true );
        break;

    case DLL_THREAD_ATTACH:
        dll_thread_attach( true, true );
        break;

    case DLL_THREAD_DETACH:
        dll_thread_detach( true, true );
        break;
    }
    return true;
}


----------------- main.d -----------------------

import std.stdio;
import core.runtime;

void main()
{
    writeln("???????????????????");
    auto h = Runtime.loadLibrary("dll.DLL");
    Runtime.unloadLibrary(h);
    writeln("!!!!!!!!!!!!!!!!!!!");
}


---------------- module.def -------------------
LIBRARY         DLL
DESCRIPTION     'DLL Module'

EXETYPE         NT
CODE            PRELOAD DISCARDABLE
DATA            WRITE

EXPORTS

----------------- RESULT -----------------------
$ dmd module.def dll.d

$ dmd -run main.d
???????????????????

----------------- (END) --------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list