You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
macOS: every mutant reports segfault when tests touch urllib.request.getproxies() (SystemConfiguration is not fork-safe) #618
Environment: mutmut 3.8.1 (also current main), Python 3.12 and 3.14 (Homebrew), macOS 27 on Apple Silicon.
What happens: if the code under test or the tests call urllib.request.getproxies() (which requests, httpx and aiohttp do when they create a client), every mutant is reported as segfault. macOS shows a crash report for each child. This is not #446: use_setproctitle already defaults to off on macOS.
Minimal reproduction:
src/demo/__init__.py
defis_adult(age):
returnage>=18
tests/test_demo.py
importurllib.requestfromdemoimportis_adultdeftest_is_adult():
urllib.request.getproxies() # what HTTP clients do on setupassertis_adult(18)
assertnotis_adult(17)
Cause: with no *_proxy environment variable set, getproxies() on macOS falls back to _scproxy.get_proxies(), which calls SCDynamicStoreCopyProxiesWithOptions (SystemConfiguration / CoreFoundation). That code isn't safe in a forked child. The crash reports show two shapes, both ending in "crashed on child side of fork pre-exec":
SIGABRT from performForkChildInitialize (objc +initialize after fork)
SIGSEGV in os_log_type_enabled under CFPreferences, with "multi-threaded process forked"
Both stacks go through get_proxies → SCDynamicStoreCopyProxiesWithOptions. Background: CPython bpo-31818.
Workaround:no_proxy='*' mutmut run. That gives killed for both mutants.
Proposed fix (#619): query the system proxy settings once in the main process, before forking, and replace urllib's two _scproxy lookups with the cached answers. Forked children inherit them, so proxy and bypass results stay identical and the environment isn't changed.
Activity