[issue33725] Python crashes on macOS after fork with no exec

Barry A. Warsaw report at bugs.python.org
Wed May 29 12:20:31 EDT 2019


Barry A. Warsaw <barry at python.org> added the comment:

On May 28, 2019, at 17:21, STINNER Victor <report at bugs.python.org> wrote:
> 
> 
> STINNER Victor <vstinner at redhat.com> added the comment:
> 
>> To be clear, what is unsafe on macOS (as of 10.13, but even more so on 10.14) is calling into the Objective-C runtime between fork and exec.  The problem for Python is that it’s way too easy to do that implicitly, thus causing the macOS to abort the subprocess in surprising ways.
> 
> Do only a few Python module use the Objective-C runtime? Or is it basically "everything"?
> 
> If it's just a few, would it be possible to emit a warning or even an exception if called in a child process after fork?

I think it’s hard to know, but I found it through a path that lead from requests to _scproxy.c.  Here’s everything I know about the subject:

https://wefearchange.org/2018/11/forkmacos.rst.html

So yes, it’s theoretically possible to do *some* between fork and exec and not crash, and it’s of course perfectly safe to call exec pretty much right after fork.  It’s just hard to know for sure, and there are surprising ways to get into the Objective-C runtime.

I think we won’t be able to work around all of Apple’s choices here.  Documentation is the best way to handle it in <=3.7, and changing the default makes sense to me for 3.8.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33725>
_______________________________________


More information about the Python-bugs-list mailing list