Skip to content
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
Next Next commit
gh-154037: Fix race in the Decimal.__hash__()
  • Loading branch information
skirpichev committed Jul 19, 2026
commit ef09f8c0cb1aaeba47175ee9ac91c1812270afa7
8 changes: 4 additions & 4 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5921,11 +5921,11 @@ static Py_hash_t
dec_hash(PyObject *op)
{
PyDecObject *self = _PyDecObject_CAST(op);
if (self->hash == -1) {
self->hash = _dec_hash(self);
}

return self->hash;
if (FT_ATOMIC_LOAD_SSIZE_RELAXED(self->hash) == -1) {
FT_ATOMIC_STORE_SSIZE_RELAXED(self->hash, _dec_hash(self));
}
return FT_ATOMIC_LOAD_SSIZE_RELAXED(self->hash);
}

/*[clinic input]
Expand Down
Loading