GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — data race on hashing of datetime objects · Issue #139774 · python/cpython

data race on hashing of datetime objects #139774

New issue
Copy link
New issue
Copy link
Closed
Closed
data race on hashing of datetime objects#139774
Copy link
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@kumaraditya303
kumaraditya303
opened on Oct 8, 2025
Issue body actions

Currently hashes of datetime objects are computed lazily as such it causes tsan warning as it is stored non-atomically.

TSAN race:

WARNING: ThreadSanitizer: data race (pid=58514)
  Read of size 8 at 0x0001104978a0 by thread T18094:
    #0 datetime_hash _datetimemodule.c:6603 (python.exe:arm64+0x1003b3cbc)
    #1 PyObject_Hash object.c (python.exe:arm64+0x10012b4d8)
    #2 setitem_take2_lock_held dictobject.c:2661 (python.exe:arm64+0x1000fb300)
    #3 _PyDict_FromItems dictobject.c:2255 (python.exe:arm64+0x1000f9b54)
    #4 _PyEval_EvalFrameDefault generated_cases.c.h:1272 (python.exe:arm64+0x10027634c)
    #5 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)
    #6 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)
    #7 method_vectorcall classobject.c:65 (python.exe:arm64+0x100084190)
    #8 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f8b0)
    #9 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)
    #10 _PyEval_EvalFrameDefault generated_cases.c.h:2616 (python.exe:arm64+0x10027bf64)
    #11 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)
    #12 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)
    #13 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)
    #14 context_run context.c:728 (python.exe:arm64+0x1002b53dc)
    #15 _PyEval_EvalFrameDefault generated_cases.c.h:3710 (python.exe:arm64+0x10027ffbc)
    #16 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)
    #17 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)
    #18 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)
    #19 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f964)
    #20 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)
    #21 thread_run _threadmodule.c:387 (python.exe:arm64+0x10041b338)
    #22 pythread_wrapper thread_pthread.h:234 (python.exe:arm64+0x100358824)

  Previous write of size 8 at 0x0001104978a0 by thread T18096:
    #0 datetime_hash _datetimemodule.c:6629 (python.exe:arm64+0x1003b3f88)
    #1 PyObject_Hash object.c (python.exe:arm64+0x10012b4d8)
    #2 setitem_take2_lock_held dictobject.c:2661 (python.exe:arm64+0x1000fb300)
    #3 _PyDict_FromItems dictobject.c:2255 (python.exe:arm64+0x1000f9b54)
    #4 _PyEval_EvalFrameDefault generated_cases.c.h:1272 (python.exe:arm64+0x10027634c)
    #5 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)
    #6 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)
    #7 method_vectorcall classobject.c:65 (python.exe:arm64+0x100084190)
    #8 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f8b0)
    #9 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)
    #10 _PyEval_EvalFrameDefault generated_cases.c.h:2616 (python.exe:arm64+0x10027bf64)
    #11 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)
    #12 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)
    #13 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)
    #14 context_run context.c:728 (python.exe:arm64+0x1002b53dc)
    #15 _PyEval_EvalFrameDefault generated_cases.c.h:3710 (python.exe:arm64+0x10027ffbc)
    #16 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)
    #17 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)
    #18 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)
    #19 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f964)
    #20 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)
    #21 thread_run _threadmodule.c:387 (python.exe:arm64+0x10041b338)
    #22 pythread_wrapper thread_pthread.h:234 (python.exe:arm64+0x100358824)

Linked PRs

  • gh-139774: use relaxed atomics for datetime hashes #139775
  • [3.14] gh-139774: use relaxed atomics for datetime hashes (GH-139775) #139780

Activity

  1. kumaraditya303
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-free-threading
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    on Oct 8, 2025
  2. kumaraditya303
    added a commit that references this issue on Oct 8, 2025

    gh-139774: use relaxed atomics for datetime hashes (#139775)

    49fb46f
  3. miss-islington
    added a commit that references this issue on Oct 8, 2025

    pythongh-139774: use relaxed atomics for datetime hashes (pythonGH-13…

    28360fa
  4. kumaraditya303
    closed this as completedon Oct 8, 2025
  5. kumaraditya303
    added a commit that references this issue on Oct 8, 2025

    [3.14] gh-139774: use relaxed atomics for datetime hashes (GH-139775) (…

    ea1ed82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.