Re:Why Ruby App Servers Break on MacOS High Sierra
by saagarjha on Thursday October 19, 2017 @06:01AM
(#15506670)
Greg Parker, who works on the Objective-C runtime, has a blog post that goes into more detail: http://www.sealiesoftware.com/blog/archive/2017/6/5/Objectiv...
[ Parent
| on HN ]
Re:Why Ruby App Servers Break on MacOS High Sierra
by hinkley on Thursday October 19, 2017 @05:09PM
(#15511573)
So, basically Objective-C doesn't like the RAII pattern if the resource is a process? Ouch.
I got the gist of his summary but his writing is a bit... awkward. Is English not his first language?
Re:Why Ruby App Servers Break on MacOS High Sierra
by valleyer on Thursday October 19, 2017 @11:49PM
(#15513436)
C has this same problem. Most of the C standard library is unsafe to use between fork and exec of a multithreaded program. This usually includes malloc and printf.
Re:Why Ruby App Servers Break on MacOS High Sierra
by dozzie on Saturday October 21, 2017 @09:47AM
(#15521821)
How so? After fork() you are guaranteed to only have one remaining thread in the child process, and the parent process doesn't care if there was a fork() or not.
Re:Why Ruby App Servers Break on MacOS High Sierra
by valleyer on Saturday October 21, 2017 @02:57PM
(#15523045)
malloc() and printf(), for example, have mutexes internal to their implementation. Suppose the parent process has two threads. One is about to do a fork, and the other is in the middle of a malloc(). The fork occurs. The parent process continues on as normal. In the child process, there is only one thread -- a clone of the forking thread, but the memory state of the child process is a full clone of the parent (except for the return value of fork(), of course).
The single thread in the child calls malloc(). But the malloc mutex is already held, because in the parent process, a thread was executing there. Unfortunately, since that thread does not exist in the child, it will never be able to release the mutex. The thread in the child is deadlocked.