-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python3Packages.pytest-xdist: Treat --forked problems on darwin #194308
Conversation
I'm seeing a test failure in |
I guess the order that the tests run is different on my machine, and It sort of looks to me like running the tests in |
Ugh, precisely why I don't want to disable I wonder if we would be better of just disabling fork safety. It's safety after all, not security. And only during tests. |
After working around the I don't have a strong opinion on whether to disable fork safety or not. As a practical matter, I have never encountered this issue, though I read on the web that some people do. I'd be fine with that option too (e.g. for poetry). In a vacuum, I would prefer to leave the option of forking to packages, but if forking solves a lot of problems that package managers / maintainers don't address, it makes sense to add it by default. |
We did see this at work using ansible and could trace it back to urllib requesting proxy settings on MacOS, so that would be pretty widespread. I think it is a fair to consider disabling fork safety, given that we only use it during tests. I pushed an update to make that happen. I welcome further input on the matter. |
I just tested this, and it turns out that the case of "YES" matters. It needs to be:
and then |
If this primarily happens when Disabling proxying during tests is fine, but it is likely only one category of failing tests, and it is somewhat likely that multiple different packages are currently failing due to similar reasons on aarch64-darwin. I mean … we could take |
We run pytest with `--forked` in nixpkgs, to reduce side effects that can occur when multiple tests mutate their environment in incompatible ways. Forking on macOS 10.13 and later is unsafe when an application does work between calls to fork() and its followup exec(). This may lead to crashes when calls into the Objective-C runtime are issued, which will in turn coredump the Python interpreter. One good reproducer for this scenario is when the urllib module tries to lookup proxy configurations in `urllib.request.getproxies()` through `get_proxies_macos_sysconf` into the native `_scproxy` module. This is a class of issues that is of course not limited to the urllib module. The general recommendation is to use `spawn` instead of `fork`, but we don't have any influence on upstream developers to do one or the other. One often cited workaround would be to disable fork safety entirely on calls to `initialize()`, which is probably a better solution than running without multithreading (slow) or without the `--forked` (prone to side effects) mode. This currently happens on aarch64-linux only, where we use more recent 11.0 SDK version, while x86_64-darwin has been stuck on 10.12 for a while now. python/cpython#77906 (comment) http://www.sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html Closes: NixOS#194290
b7a7d41
to
2ba40b5
Compare
I think we should give |
We run pytest with
--forked
in nixpkgs, to reduce side effects thatcan occur when multiple tests mutate their environment in incompatible
ways.
Forking on macOS 10.13 and later is unsafe when an application does work
between calls to fork() and its followup exec(). This may lead to
crashes when calls into the Objective-C runtime are issued, which will
in turn coredump the Python interpreter.
One good reproducer for this scenario is when the urllib module tries
to lookup proxy configurations in
urllib.request.getproxies()
throughget_proxies_macos_sysconf
into the native_scproxy
module.This is a class of issues that is of course not limited to the urllib
module. The general recommendation is to use
spawn
instead offork
,but we don't have any influence on upstream developers to do one or the
other.
One often cited workaround would be to disable fork safety entirely on
calls to
initialize()
, which is probably a better solution thanrunning without multithreading (slow) or without the
--forked
(proneto side effects) mode.
This currently happens on aarch64-linux only, where we use more recent
11.0 SDK version, while x86_64-darwin has been stuck on 10.12 for a
while now.
python/cpython#77906 (comment)
http://www.sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html
Closes: #194290
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes