Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closefrom check is too strict #112970

Closed
thesamesam opened this issue Dec 11, 2023 · 2 comments
Closed

closefrom check is too strict #112970

thesamesam opened this issue Dec 11, 2023 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@thesamesam
Copy link
Contributor

thesamesam commented Dec 11, 2023

Bug report

Bug description:

closefrom(3) is available with >=glibc-2.34 on Linux (and Hurd, but, well...)

The check in Python/fileutils.c is a bit too strict, as it hardcodes FreeBSD. This excludes both the aforementioned systems but also other BSDs where I believe it's available.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@thesamesam thesamesam added the type-bug An unexpected behavior, bug, or error label Dec 11, 2023
thesamesam added a commit to thesamesam/cpython that referenced this issue Dec 11, 2023
glibc-2.34 implements closefrom(3) using the same semantics as on BSD. Check
for closefrom in configure and use the check result in fileutils.c rather than
hardcoding a FreeBSD check (which was wrong for other BSDs anyway).

Signed-off-by: Sam James <sam@gentoo.org>
thesamesam added a commit to thesamesam/cpython that referenced this issue Dec 11, 2023
glibc-2.34 implements closefrom(3) using the same semantics as on BSD. Check
for closefrom in configure and use the check result in fileutils.c rather than
hardcoding a FreeBSD check (which was wrong for other BSDs anyway).

Signed-off-by: Sam James <sam@gentoo.org>
@thesamesam
Copy link
Contributor Author

We noticed this when poking at a swarm of close calls on an older kernel.

erlend-aasland pushed a commit that referenced this issue Dec 12, 2023
glibc-2.34 implements closefrom(3) using the same semantics as on BSD.
Check for closefrom() in configure and use the check result in
fileutils.c, rather than hardcoding a FreeBSD check.

Some implementations of closefrom() return an int. Explicitly discard 
the return value by casting it to void, to avoid future compiler
warnings.

Signed-off-by: Sam James <sam@gentoo.org>
@erlend-aasland
Copy link
Contributor

aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…2969)

glibc-2.34 implements closefrom(3) using the same semantics as on BSD.
Check for closefrom() in configure and use the check result in
fileutils.c, rather than hardcoding a FreeBSD check.

Some implementations of closefrom() return an int. Explicitly discard 
the return value by casting it to void, to avoid future compiler
warnings.

Signed-off-by: Sam James <sam@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants