[issue31818] [macOS] _scproxy.get_proxies() crash -- get_proxies() is not fork-safe?

STINNER Victor report at bugs.python.org
Thu Oct 19 08:36:40 EDT 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

Hi, can you please explain how to reproduce your issue?

According to the crash report, it seems like you are running Ansible on macOS and that the Python function _scproxy.get_proxies() was called.

get_proxies() calls CFPreferencesCopyAppValue() which calls indirectly performForkChildInitialize(). It seems like Ansible forked the process or something like that. Finally, performForkChildInitialize() calls _objc_fatal() which kills the process with abort().

The parent process is also Python ("Parent Process: python2.7 [4305]") which confirms that the application used fork().

See also:

* bpo-9405: Similar but old (2010) crash caused by SCDynamicStoreCopyProxies in a small Python application using multiprocessing and so using fork
* bpo-27126: "Apple-supplied libsqlite3 on OS X is not fork safe;  can cause crashes"
* "fork() without exec() is dangerous in large programs" article by Evan Jones (2016-August-16): http://www.evanjones.ca/fork-is-dangerous.html -- this article mentions bpo-27126

Ned Deily's advice from bpo-9405: "A quick workaround is to make a [get_proxies()] call from the main process."

IMHO the safest fix is to not run any Python program after fork(). Using use subprocess to use fork() immmediately followed by exec(). It's not safe to execute code after fork(), many functions are not "fork safe". But I know that many applications don't care, since there is also a lot of functions which are fork safe...

----------
nosy: +haypo
title: macOS HighSierra final - Python Crash because of _scproxy -> [macOS] _scproxy.get_proxies() crash -- get_proxies() is not fork-safe?

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


More information about the Python-bugs-list mailing list