-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
Issue #15538 established that a process which has loaded a Go shared library (and therefore, instantiated the Go runtime) cannot call fork()
and make use of Go code in child processes.
I tested the inverse; forking multiple processes and then loading a Go library in each child via dlopen()
. I expected this to work but unfortunately I hit similar behaviors to the other issue; semaphore errors, file descriptor errors, dead locks, etc.
To reproduce the issue:
- write a Go shared library which exports symbols to C and calls multithreaded functions like
net.Dial
- write a C program which forks more than once
- in each child process, call
dlopen
to load the Go library - call a multithreaded function in the Go library
The first child to make use of the Go library should succeed. Subsequent calls should behave undefined. Symptoms differ between OS.
Confirmed on Go v1.5.4 and v1.6.2 on Red Hat 7.2 and OS X 10.11.4 x86_64.
Example code to reproduce this issue is available on gist:https://gist.github.com/cavaliercoder/68bb2ee0d673cb3d585199fe189fb171