sb-posix:fork doesn't update the list of threads
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Medium
|
Unassigned |
Bug Description
;; forkthread.lisp
(require :sb-posix)
(sb-thread:
(let ((pid (sb-posix:fork)))
(if (zerop pid)
(sb-ext:quit)
(sb-
% sbcl --load forkthread.lisp
(running SBCL from: /home/sky)
This is SBCL 1.0.31.26, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
; loading system definition from
; /home/sky/
; #<PACKAGE "ASDF1">
; registering #<SYSTEM SB-GROVEL {B2AFB41}> as SB-GROVEL
fatal error encountered in SBCL pid 7933(tid 3084954384):
kill_safely: pthread_kill failed with 3
This error occurs because sb-thread:
The relevant part of POSIX states:
“A process shall be created with a single thread. If a multi-threaded process calls fork(), the new process shall contain a replica of the calling thread [...]”
Proposal: change the behavior of sb-posix:fork to take this into account, resetting the list of threads in *all-threads* to the one active thread.
Changed in sbcl: | |
importance: | Undecided → Medium |
status: | Fix Committed → Fix Released |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
"A process shall be created with a single thread. If a multi-threaded process calls fork(), the new process shall contain a replica of the calling thread and its entire address space, possibly including the states of mutexes and other resources. Consequently, to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called."
The "consequently" part basically means that you are extremely limited in what you can do after forking a threaded program. I'm tempted to say that having the wrong value for *all-threads* is the least of your problems.