8000 gh-120837: Update _Py_DumpExtensionModules to be async-signal-safe by corona10 · Pull Request #121051 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

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

Merged
merged 8 commits into from
Jun 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Jun 27, 2024
commit e7f24af4c642a1ee49dd8f9ada6f16fb6818b0b1
3 changes: 2 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,8 @@ release_dict_lock_for_dump(PyObject *obj) {
#ifdef Py_GIL_DISABLED
PyMutex *mutex = &obj->ob_mutex;
uint8_t expected = _Py_LOCKED;
// Do not wake up other threads.
// We can not call PyMutex_Unlock because it's not async-signal-safe.
// So not to wake up other threads, we just use a simple CAS in here.
_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)

#else
return;
Expand Down
Loading
0