-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Closed
Labels
topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Frozenset's hash has code to cache the hash computation that is not thread-safe under free-threading:
Line 796 in b0f77c4
if (so->hash != -1) { |
TSAN report from JAX test suite under Python 3.14:
WARNING: ThreadSanitizer: data race (pid=145260)
Read of size 8 at 0x7fffb70ee4a0 by thread T6 (mutexes: read M0):
#0 frozenset_hash /__w/jax/jax/cpython/Objects/setobject.c:796:13 (python3.14+0x2e1d93) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#1 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#2 tuple_hash /__w/jax/jax/cpython/Objects/tupleobject.c:321:27 (python3.14+0x2f34bf) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#3 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#4 builtin_hash /__w/jax/jax/cpython/Python/bltinmodule.c:1736:9 (python3.14+0x3f0915) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
...
Previous write of size 8 at 0x7fffb70ee4a0 by thread T1 (mutexes: read M0):
#0 frozenset_hash /__w/jax/jax/cpython/Objects/setobject.c:801:14 (python3.14+0x2e1ec3) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#1 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#2 tuple_hash /__w/jax/jax/cpython/Objects/tupleobject.c:321:27 (python3.14+0x2f34bf) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#3 PyObject_Hash /__w/jax/jax/cpython/Objects/object.c (python3.14+0x2a6876) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
#4 builtin_hash /__w/jax/jax/cpython/Python/bltinmodule.c:1736:9 (python3.14+0x3f0915) (BuildId: 36ce1663ba151019a0cc812ec2af69c6b980a390)
...
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error