Skip to content

Conversation

@markovejnovic
Copy link

Fixes #540

This PR implements a happy path for closing large arrays of file descriptors on Linux. This could also be implemented on FreeBSD, but I do not have a FreeBSD machine I can test this on.

@google-cla
Copy link

google-cla bot commented Nov 13, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@markovejnovic
Copy link
Author

I have confirmed that this implementation solves my problem. I don't know how helpful this strace -f log is for you, but it seems that we use close_range successfully.

[pid 280940] dup2(14, 100)              = 100
[pid 280940] dup2(13, 101)              = 101
[pid 280940] dup2(8, 102)               = 102
[pid 280940] dup2(7, 103)               = 103
[pid 280940] prlimit64(0, RLIMIT_CORE, {rlim_cur=0, rlim_max=0}, NULL) = 0
[pid 280940] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 280940] close(14)                  = 0
[pid 280940] close(13)                  = 0
[pid 280940] openat(AT_FDCWD, "/dev/null", O_RDWR) = 13
[pid 280940] dup2(13, 0)                = 0
[pid 280940] dup2(9, 1)                 = 1
[pid 280940] dup2(10, 2)                = 2
[pid 280940] close(13)                  = 0
[pid 280940] uname({sysname="Linux", nodename="fedora", ...}) = 0
[pid 280940] prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=512*1024}) = 0
[pid 280940] close_range(4, 99, 0)      = 0
[pid 280940] close_range(104, 1023, 0)  = 0

Attaching full strace log (notice I aborted the program a couple seconds in, since the issue arises early).

strace.debug.log

Also tested that my docker container successfully runs fuzzilli under root with the absurdly large RLIMIT_NOFILE.

@markovejnovic markovejnovic marked this pull request as ready for review November 13, 2025 18:50
@markovejnovic markovejnovic deleted the u/markovejnovic/close_range branch November 13, 2025 18:53
@markovejnovic markovejnovic restored the u/markovejnovic/close_range branch November 13, 2025 18:53
@markovejnovic markovejnovic reopened this Nov 13, 2025
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.

Large RLIMIT_NOFILE causes application hang

1 participant