[3.14] gh-140257: fix data race on eval_breaker during finalization (GH-140265) (#140294)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run

gh-140257: fix data race on eval_breaker during finalization (GH-140265)
(cherry picked from commit c8729c9909)

Co-authored-by: Shamil <ashm.tech@proton.me>
This commit is contained in:
Miss Islington (bot) 2025-10-18 13:28:53 +02:00 committed by GitHub
parent c70f409da0
commit 3ca7ea1f8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -860,10 +860,11 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
Py_CLEAR(interp->audit_hooks);
// At this time, all the threads should be cleared so we don't need atomic
// operations for instrumentation_version or eval_breaker.
// gh-140257: Threads have already been cleared, but daemon threads may
// still access eval_breaker atomically via take_gil() right before they
// hang. Use an atomic store to prevent data races during finalization.
interp->ceval.instrumentation_version = 0;
tstate->eval_breaker = 0;
_Py_atomic_store_uintptr(&tstate->eval_breaker, 0);
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
interp->monitors.tools[i] = 0;