Skip to content

Protect Spindle's FDs from close_range, closefrom - #224

Merged
mplegendre merged 2 commits into
llnl:develfrom
ParaToolsInc:close-range
Oct 2, 2026
Merged

mplegendre merged 2 commits into
llnl:develfrom
ParaToolsInc:close-range

Conversation

@nchaimov

@nchaimov nchaimov commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

glibc 2.34 added the functions close_range, which closes a range of file descriptors, and closefrom which closes all file descriptors from a given fd up, using a new close_range syscall added in Linux 5.9. Python 3.12 and newer use close_range, if available, to close file descriptors. This is the cause of issue #218: when using subprocess to launch a subprocess, Python uses close_range to close all FDs starting from 3. Spindle's close wrapper avoids closing Spindle's internal FDs, but since close_range is 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_range and closefrom which convert these into a sequence of close_range calls omitting Spindle's FDs. It also adds a new test which checks this behavior by opening a file, using close_range or closefrom to 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 support close_range or the glibc is older than 2.34.

With this change, the lbann and h5bench E4S tests now pass under Spindle. No new failures occur.

Fixes #218.

@nchaimov
nchaimov requested a review from mplegendre October 1, 2026 21:55
@nchaimov
nchaimov deployed to Spindle CI October 1, 2026 21:55 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 1, 2026 21:55 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 1, 2026 21:55 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 1, 2026 21:55 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 1, 2026 21:55 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 1, 2026 21:55 — with GitHub Actions Active
@mplegendre
mplegendre merged commit 4638b9d into llnl:devel Oct 2, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Spindle CI — c77acbd7 Deployed Oct 1, 2026 by nchaimov via Testsuite (Flux, Ubuntu) #272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spindle breaks Python subprocess

2 participants