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

gh-120837: Update _Py_DumpExtensionModules to be async-signal-safe #121051

Merged
merged 8 commits into from
Jun 27, 2024

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Jun 26, 2024

PyMutex *mutex = &obj->ob_mutex;
uint8_t expected = _Py_UNLOCKED;
// Do not wake up other threads.
_Py_atomic_compare_exchange_uint8(&mutex->_bits, &expected, _Py_UNLOCKED);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to run for loop to prevent CAS failure?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a _Py_atomic_store_uint8(&mutex->_bits, _Py_UNLOCKED)

@corona10 corona10 requested a review from vstinner June 27, 2024 11:10
@corona10 corona10 requested a review from vstinner June 27, 2024 11:33
@corona10
Copy link
Member Author

@colesbury PTAL :)

PyMutex *mutex = &obj->ob_mutex;
uint8_t expected = _Py_UNLOCKED;
// Do not wake up other threads.
_Py_atomic_compare_exchange_uint8(&mutex->_bits, &expected, _Py_UNLOCKED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a _Py_atomic_store_uint8(&mutex->_bits, _Py_UNLOCKED)

@corona10 corona10 requested a review from colesbury June 27, 2024 20:53
Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this!

(I left one minor comment inline. Up to you what you want to do with it.)

Comment on lines 2922 to 2923
#else
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #else return; doesn't do anything. I would delete it, but up to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@corona10 corona10 merged commit 1a2e7a7 into python:main Jun 27, 2024
34 checks passed
@miss-islington-app
Copy link

Thanks @corona10 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 27, 2024
@bedevere-app
Copy link

bedevere-app bot commented Jun 27, 2024

GH-121107 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 27, 2024
@corona10 corona10 deleted the gh-120837 branch June 27, 2024 21:47
corona10 added a commit that referenced this pull request Jun 27, 2024
…safe (gh-121051) (gh-121107)

gh-120837: Update _Py_DumpExtensionModules to be async-signal-safe (gh-121051)
(cherry picked from commit 1a2e7a7)

Co-authored-by: Donghee Na <[email protected]>
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
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.

3 participants