Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-104372: Unlock the GIL before exec when using vfork().#104515

Closed
gpshead wants to merge 1 commit intopython:mainfrom
gpshead:subprocess-vfork-gil-release-before-exec
Closed

gh-104372: Unlock the GIL before exec when using vfork().#104515
gpshead wants to merge 1 commit intopython:mainfrom
gpshead:subprocess-vfork-gil-release-before-exec

Conversation

@gpshead
Copy link
Member

@gpsheadgpshead commentedMay 15, 2023
edited by bedevere-bot
Loading

See code comments, this still needs work and likely should not be written this way.

Basically this solves the#104372 problem by unlocking the GIL before the child exec(). In the scariest way possible: it's a vforked child running in the parent vfork-calling thread address space, so the child "can" just do the unlock itself.

This proves the concept that it works when using a local test case involving an executable on a very slow filesystem.

But it doesn't feel clean to do it this way...

The proper approach would be a more traditional proper looking "all done in the parent" release the GIL before the vfork() call and reacquire in the parent afterwards code.

BUT we can't yet do that without some refactoring: child_exec() makes some Python C API calls that require the GIL to be held (!) the worst of them being in the existingmake_inheritable() function which calls PyLong_AsLong() and PyErr_Occurred() (which asserts that the GIL is held).

We need to clean that code up anyways to have turned that tuple of ints into a C array of longs in the parent process before forking as while mostly async signal "safe" today, we shouldn't make that assumption as it is not guaranteed. After which I believe we'll be able to consider the more traditional drop GIL before vfork approach.

See comments, this still needs work and likely should not be writtenthis way.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

@gpsheadgpshead

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@gpshead

Comments


[8]ページ先頭

©2009-2026 Movatter.jp