Skip to content

[rocr-runtime] Data race on AsyncEventsControl::exit flag during hsa_shut_down #3342

@nurmukhametov

Description

@nurmukhametov

ThreadSanitizer reports a data race on AsyncEventsControl::exit between the async-events polling thread and the main thread during hsa_shut_down() teardown. It is observed during a TSAN-enabled build.

WARNING: ThreadSanitizer: data race (pid=1841796)
  Read of size 1 at 0x725400001648 by thread T257:
    #0 rocr::core::Runtime::AsyncEventsLoop(void*) runtime.cpp:1812

  Previous write of size 1 at 0x725400001648 by main thread (mutexes: write M0):
    #0 rocr::core::Runtime::AsyncEventsControl::Shutdown() runtime.cpp:2840
    ...
    #6 rocr::core::Runtime::Unload() runtime.cpp:2469
    #7 rocr::core::Runtime::Release() runtime.cpp:167
    #8 rocr::HSA::hsa_shut_down() hsa.cpp:213

SUMMARY: ThreadSanitizer: data race runtime.cpp:1812 in
         rocr::core::Runtime::AsyncEventsLoop(void*)

The exit field is a plain bool that is written by the main thread in Shutdown() and read concurrently by the event-loop thread in AsyncEventsLoop() without synchronization. Per the C++ memory model this is undefined behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions