Skip to content

Commit a93ff87

Browse files
[3.14] gh-135641: Fix flaky test_capi.test_lock_two_threads test case (gh-135642) (gh-135687)
The mutex may have the `_Py_HAS_PARKED` bit set. (cherry picked from commit 17ac393) Co-authored-by: Sam Gross <[email protected]>
1 parent 1734b29 commit a93ff87

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/_testinternalcapi/test_lock.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ lock_thread(void *arg)
5757
_Py_atomic_store_int(&test_data->started, 1);
5858

5959
PyMutex_Lock(m);
60-
assert(m->_bits == 1);
60+
// gh-135641: in rare cases the lock may still have `_Py_HAS_PARKED` set
61+
// (m->_bits == 3) due to bucket collisions in the parking lot hash table
62+
// between this mutex and the `test_data.done` event.
63+
assert(m->_bits == 1 || m->_bits == 3);
6164

6265
PyMutex_Unlock(m);
6366
assert(m->_bits == 0);

0 commit comments

Comments
 (0)