[vm] Fix one race reported in DEBUG+TSAN mode

The SafepointHandler::IsOwnedByTheThread() is used in a few
ASSERT()/RELEASE_ASSERT() and accesses the [owner_] field
unsynchronized.

Issue https://github.com/dart-lang/sdk/issues/47788

TEST=Fixes one race reported when building TSAN in DEBUG mode.

Change-Id: I64371265d60c9bb68c299d1c1e8abc2175b33bc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221331
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann 2021-11-26 15:52:53 +00:00 committed by Commit Bot
parent d7e55c4d1b
commit a3fa6b4c52

View file

@ -76,6 +76,7 @@ class SafepointHandler {
void BlockForSafepoint(Thread* T);
bool IsOwnedByTheThread(Thread* thread) {
MonitorLocker ml(threads_lock());
for (intptr_t level = 0; level < SafepointLevel::kNumLevels; ++level) {
if (handlers_[level]->owner_ == thread) {
return true;