MPS issue job004062

Titlefork() unsupported on FreeBSD, Linux and macOS
Statusclosed
Priorityoptional
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionChristian Schafmeister would like to be able to call fork() in a process that is running the MPS [1]. The problems with this are:

1. The MPS might be holding a lock in thread B when the fork() occurs in thread A. This lock would never be released, since the child process only has a fork of thread A.
2. On OS X, the MPS starts a thread whose job is to handle memory protection exceptions; after fork(), this thread won’t be running in the child so memory protection exceptions will not be handled. See protxc.c.
AnalysisFor problem (2), the MPS on OS X could call pthread_atfork with a "child" handler that restarts the exception handler thread.

For problem (1), the MPS would have to claim all the locks in the "prepare" handler and then release them in the "parent" and "child" handlers. (The pthread_atfork POSIX specification recommends this approach explicitly: "The expected usage is that the prepare handler acquires all mutex locks and the other two fork handlers release them.")
How foundcustomer
Evidence[1] https://info.ravenbrook.com/mail/2018/06/12/15-30-04/0/
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html
Created byGareth Rees
Created on2018-06-12 17:18:10
Last modified byGareth Rees
Last modified on2018-06-15 11:41:32
History2018-06-12 GDR Created.

Fixes

Change Effect Date User Description
193816 closed 2018-06-15 11:41:32 Gareth Rees Merge branch/2018-06-13/fork.