D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4368 - Fork() on OS X 2.047 results in a core.thread.ThreadException
Summary: Fork() on OS X 2.047 results in a core.thread.ThreadException
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: x86 Mac OS X
: P2 normal
Assignee: Sean Kelly
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-22 16:12 UTC by Byron Heads
Modified: 2020-01-16 13:32 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Byron Heads 2010-06-22 16:12:46 UTC
import  core.sys.posix.unistd,
        std.stdio;

void main() 
{
    auto pid = fork();

    if( pid > 0 ) {
        writeln( "Parent" );
    } else if( pid == 0 ) {
        writeln( "Child" );
    } else {
        writeln( "Failed to fork!" );
    }
}


$ ./fork
Parent
Child
core.thread.ThreadException: Unable to load thread state
----------------
5   fork                                0x00006e0d thread_suspendAll + 85
6   fork                                0x0000b014 D2gc3gcx3Gcx11fullcollectMFPvZk + 32
7   fork                                0x0000afe1 D2gc3gcx3Gcx16fullcollectshellMFZk + 41
8   fork                                0x0000a0c6 D2gc3gcx2GC18fullCollectNoStackMFZv + 54
9   fork                                0x00008060 gc_term + 44
10  fork                                0x0000cf1a D2rt6dmain24mainUiPPaZi6runAllMFZv + 90
11  fork                                0x0000cdea D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv + 42
12  fork                                0x0000cd78 main + 168
13  fork                                0x00001acd start + 53halle109-82:dbug admin$
Comment 1 Heywood Floyd 2010-06-23 07:02:57 UTC
// Workaround (+ possible clue to what the cause is)


import  core.sys.posix.unistd,
      core.thread, //++++
        std.stdio;

void main() 
{
    auto pid = fork();

    if( pid > 0 ) {
        writeln( "Parent" );
    } else if( pid == 0 ) {
        thread_attachThis(); // ++++
        writeln( "Child" );
    } else {
        writeln( "Failed to fork!" );
    }
}:
Comment 2 Mathias LANG 2020-01-16 13:32:02 UTC
This isn't an issue anymore.