Skip to content

fix: lock two caches in address order in __eq__ and __ne__ - #122

Merged
awolverp merged 2 commits into
awolverp:mainfrom
greenclaw:fix/two-cache-locks
Oct 29, 2026
Merged

awolverp merged 2 commits into
awolverp:mainfrom
greenclaw:fix/two-cache-locks

Conversation

@greenclaw

Copy link
Copy Markdown
Contributor

Part of #118: __eq__ / __ne__ locked self and then other, so a == b on one thread and b == a on another could each hold one lock and wait for the other. They now take both locks through Wrapped::policy_pair_py_attached, which always locks the two caches in address order.

test_compare_with_arguments_swapped runs a == b / a != b and b == a / b != a on two threads in a child process, with keys whose __eq__ is Python code so the threads switch while the locks are held.

  • Fork CI with the test alone on main (run): it hangs for all 7 classes on ubuntu 3.10–3.15, 3.14t and pypy3.11, and for some of them on macos, windows and 3.15t.
  • With the fix (run): all jobs green.

update() from the same issue is not in this PR; I described why there in the issue.

@awolverp
awolverp merged commit 4d57c90 into awolverp:main Oct 29, 2026
12 checks passed
@greenclaw
greenclaw deleted the fix/two-cache-locks branch October 29, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants