Protect Spindle's FDs from close_range, closefrom - #224
Merged
Merged
Conversation
This branch was successfully deployed
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.
glibc 2.34 added the functions
close_range, which closes a range of file descriptors, andclosefromwhich closes all file descriptors from a given fd up, using a newclose_rangesyscall added in Linux 5.9. Python 3.12 and newer useclose_range, if available, to close file descriptors. This is the cause of issue #218: when usingsubprocessto launch a subprocess, Python usesclose_rangeto close all FDs starting from 3. Spindle'sclosewrapper avoids closing Spindle's internal FDs, but sinceclose_rangeis used instead, Spindle's FDs are closed in the child process, and Spindle subsequently can't communicate with the server to look up the path to exec. This problem wouldn't have been seen on LLNL systems because both the kernel and glibc versions predate these.This PR fixes the problem by adding wrappers for
close_rangeandclosefromwhich convert these into a sequence ofclose_rangecalls omitting Spindle's FDs. It also adds a new test which checks this behavior by opening a file, usingclose_rangeorclosefromto close all FDs from 3 up, then verifying that the FD was in fact closed and that we can still exec another executable. The test fails without the fix and passes with it. The test is skipped if the kernel doesn't supportclose_rangeor the glibc is older than 2.34.With this change, the
lbannandh5benchE4S tests now pass under Spindle. No new failures occur.Fixes #218.