Skip to content

gh-153400: Use glibc functions instead of syscall() - #155518

Open
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:pidfd
Open

gh-153400: Use glibc functions instead of syscall()#155518
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:pidfd

Conversation

@vstinner

@vstinner vstinner commented Aug 10, 2026

Copy link
Copy Markdown
Member

Use glibc functions instead of syscall(): pidfd_open(), pidfd_getfd() and pidfd_send_signal() (glibc 2.36), gettid() and getdents64() (glibc 2.30), and getrandom() (glibc 2.25).

Use unsigned int for os.getrandom() flags and signal.pidfd_send_signal() flags.

Use glibc functions instead of syscall(): pidfd_open(), pidfd_getfd()
and pidfd_send_signal() (glibc 2.36), gettid() and getdents64()
(glibc 2.30), and getrandom() (glibc 2.25).
@vstinner
vstinner requested a review from gpshead as a code owner August 10, 2026 21:06
@vstinner vstinner changed the title gh-153400: Use pidfd_open() and pidfd_getfd() functions gh-153400: Use glibc functions instead of syscall() Aug 10, 2026
Use unsigned int for os.getrandom() flags and
signal.pidfd_send_signal() flags.
@vstinner

Copy link
Copy Markdown
Member Author

@thesamesam:

For some syscall wrappers, glibc has _FORTIFY_SOURCE checks on the arguments. CPython right now doesn't ever use glibc wrappers (uses syscall instead), it just uses glibc for the syscall numbers, which means the status quo is the worst-of-both-worlds: you get no protection or sanity checks, but you also need a newer glibc that acknowledges the syscall exists. The number could also come from linux-headers.

I think CPython should use the glibc wrappers if they exist at build-time at least.

I wrote this change to replace syscall() calls with glibc function calls here instead. Is it what you proposed?

@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Aug 11, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit b6bbfd9 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F155518%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Aug 11, 2026
@thesamesam

Copy link
Copy Markdown
Contributor

I wrote this change to replace syscall() calls with glibc function calls here instead. Is it what you proposed?

It looks good, thank you!

@vstinner

Copy link
Copy Markdown
Member Author

buildbot/AMD64 Android PR — Build done.

The "test" step failed with a timeout, not good. I'm not sure if it's related to the change or not.

@mhsmith

mhsmith commented Aug 11, 2026

Copy link
Copy Markdown
Member

!buildbot AMD64 Android

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @mhsmith for commit b6bbfd9 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F155518%2Fmerge

The command will test the builders whose names match following regular expression: AMD64 Android

The builders matched are:

  • AMD64 Android PR

@mhsmith

mhsmith commented Aug 11, 2026

Copy link
Copy Markdown
Member

The buildbot stopped working about 24 hours ago, so it's not related to this change. Testing manually, it appeared to work on the first run within each Gradle daemon, but if I interrupted it and tried again, it hung while starting the emulator. Removing the emulator snapshot and allowing it to be recreated seems to have fixed the issue.

@mhsmith

mhsmith commented Aug 11, 2026

Copy link
Copy Markdown
Member

No, apparently not, and it looks like this previously happened for a few runs in a row on August 5, then again on August 6. Since the Gradle daemon is hanging with no emulator process running, this was probably caused by the Gradle update on August 1 (#155012).

I'll shut the buildbot down until I have a chance to look into this. Notes to self:

  • Check the version of platform-tools, emulator, or any other SDK packages that may be involved. Match the versions on GitHub Actions, or the other buildbot, but keep a record of the previous versions (see notes in Android buildbot failures after updating to API level 35 #142387).
  • Switch to Java 25, since that's what this version of AGP is best tested with.
  • Switch to an older version of AGP which is still compatible with Java 25.
  • Revert the update completely.

We still have x86_64 being tested by GitHub Actions, and aarch64 by the other buildbot, so it doesn't need to block this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants