gh-109981: Fix support.fd_count() on macOS 14#112797
Merged
ronaldoussoren merged 3 commits intopython:mainfrom Dec 7, 2023
Merged
gh-109981: Fix support.fd_count() on macOS 14#112797ronaldoussoren merged 3 commits intopython:mainfrom
ronaldoussoren merged 3 commits intopython:mainfrom
Conversation
This fixes a crash on macOS 14 when running ``./python.exe -m test test_sax test_socket test_support``. The root cause of this is a macOS feature where file descriptors used by system libraries are guarded an will cause a hard crash when used in "user" code.
vstinner
approved these changes
Dec 6, 2023
Member
vstinner
left a comment
There was a problem hiding this comment.
LGTM but:
- I made a minor coding style suggestion.
- The PR title is misleading. What does "test crash" means? I suggest to refer to support.fd_count() instead. For example, "Fix support.fd_count() on macOS".
Member
|
On FreeBSD, maybe we should try |
Co-authored-by: Victor Stinner <vstinner@python.org>
Contributor
Author
Good suggestions. Thanks for the review! |
Contributor
Author
That should be a separate issue. I cannot easily test on FreeBSD and am not a fan of debugging through CI. |
|
Thanks @ronaldoussoren for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Dec 7, 2023
Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors. "Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code. (cherry picked from commit 953ee62) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> Co-authored-by: Victor Stinner <vstinner@python.org>
|
GH-112824 is a backport of this pull request to the 3.12 branch. |
|
GH-112825 is a backport of this pull request to the 3.11 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Dec 7, 2023
Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors. "Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code. (cherry picked from commit 953ee62) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> Co-authored-by: Victor Stinner <vstinner@python.org>
ronaldoussoren
added a commit
that referenced
this pull request
Dec 7, 2023
…2824) gh-109981: Fix support.fd_count() on macOS 14 (GH-112797) Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors. "Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code. (cherry picked from commit 953ee62) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> Co-authored-by: Victor Stinner <vstinner@python.org>
ronaldoussoren
added a commit
that referenced
this pull request
Dec 7, 2023
…2825) gh-109981: Fix support.fd_count() on macOS 14 (GH-112797) Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors. "Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code. (cherry picked from commit 953ee62) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> Co-authored-by: Victor Stinner <vstinner@python.org>
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors. "Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code. Co-authored-by: Victor Stinner <vstinner@python.org>
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this pull request
Sep 2, 2024
Use scanning "/dev/fd/" on macOS in support.fd_count(). That's both more efficient than scanning all possible file descriptors, and avoids crashing the interpreter when there are open "guarded" file descriptors. "Guarded" file descriptors are a macOS feature where file descriptors used by system libraries are marked and cause hard crashes when used by "user" code. Co-authored-by: Victor Stinner <vstinner@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a crash on macOS 14 when
running
./python.exe -m test test_sax test_socket test_support.The root cause of this is a macOS feature where file descriptors used by system libraries are guarded an will cause a hard crash when used in "user" code.