Skip to content

TSan-reported race during finialization #149043

@dpdani

Description

@dpdani

Bug report

Bug description:

I've seen this TSan warning while working on another issue:

WARNING: ThreadSanitizer: data race (pid=98545)
  Write of size 8 at 0x000102f27828 by main thread:
    #0 _PyFaulthandler_Fini faulthandler.c:1509 (python.exe:arm64+0x1001d4604)
    #1 _Py_Finalize pylifecycle.c:2489 (python.exe:arm64+0x100199fe8)

  Previous read of size 8 at 0x000102f27828 by thread T41:
    #0 faulthandler_thread faulthandler.c:714 (python.exe:arm64+0x1001d7100)
    #1 pythread_wrapper thread_pthread.h:234 (python.exe:arm64+0x1001b7820)

  Location is global '_PyRuntime' at 0x000102f25200 (python.exe+0x10053b828)

  Thread T41 (tid=1315473, finished) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x335b8)
    #1 do_start_joinable_thread thread_pthread.h:281 (python.exe:arm64+0x1001b74c8)
    #2 PyObject_Vectorcall call.c:327 (python.exe:arm64+0x1000404e0)

SUMMARY: ThreadSanitizer: data race faulthandler.c:1509 in _PyFaulthandler_Fini

After a first look, the fix seems pretty trivial, so I might push a PR later today.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions