Repository navigation
fix(macos): return interfaces instead of crashing when out of file descriptors - #203
Merged
Merged
Conversation
…scriptors When the process has no free descriptors, the plist read fails with EMFILE and the fallback to SCNetworkInterfaceCopyAll crashes inside CoreFoundation. Return the interfaces without SC metadata instead. Fixes shellrow#202
Owner
|
Thanks for the fix and verifying! |
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.
Fixes #202.
On macOS,
get_interfaces()crashes the process with SIGSEGV when the process has no free file descriptors. The plist read fails with EMFILE, andinterfaces()then falls back toget_sc_interface_map(). In that stateSCNetworkInterfaceGetLocalizedDisplayNamecrashes inside CoreFoundation (the backtrace is in the issue).This change skips the SystemConfiguration fallback when the plist read fails with EMFILE or ENFILE.
interfaces()then returns the interfaces fromgetifaddrswithout the SC metadata: no friendly name and no DHCP flags. Every other plist error still takes the fallback, as before.Testing
On a Mac mini with macOS 26.6.1, I used the repro from the issue with
ulimit -n 256. It also callsget_interfaces()a second time after it frees the descriptors:cargo test,cargo test --all-featuresandcargo test --no-default-featurespass. They include a new unit test for the EMFILE/ENFILE check.cargo fmt --all --checkis clean.