389aab624d
This is a revert of b6bbfff8c0c6c44cdab0d7d78 which temporarily disabled
this.
Turns out that a non-TSAN gen_snapshot would - when emitting code via
`Assembler::TsanLoadAcquire` - use an incorrect `Thread`-offset:
It calculated the offset via `Thread::OffsetFromThread`. That function
took a `dart::RuntimeEntry*` and tried to find its offset.
We happen to have the following leaf runtime entries:
#define LEAF_RUNTIME_ENTRY_LIST(V)
...
V(void, MsanUnpoison, void*, size_t)
V(void, MsanUnpoisonParam, size_t)
V(void, TsanLoadAcquire, void*)
V(void, TsanStoreRelease, void*)
...
It loops over all runtime entries and finds the first one that has the
identical `dart::RuntimeEntry::function_` pointer.
Though all 4 of them are `nullptr` at `gen_snapshot` time, so when
searching for offset for
`Thread::OffsetFromThread(kTsanLoadAcquireRuntimeEntry)`
it looked for the first runtime entry with `nullptr` function pointer -
which turned out to be `MsanUnpoison` (instead of `TsanLoadAcquire`).
=> The obvious fix is to use the `dart::RuntimeEntry*` pointer for
comparison instead of it's `function_` member.
TEST=ci
Issue b/287638965
Change-Id: I85c06674927978ef8561e9e7bdfab4823c0a8e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312902
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_PLATFORM_THREAD_SANITIZER_H_
|
|
#define RUNTIME_PLATFORM_THREAD_SANITIZER_H_
|
|
|
|
#include "platform/globals.h"
|
|
|
|
#if defined(__has_feature)
|
|
#if __has_feature(thread_sanitizer)
|
|
#define USING_THREAD_SANITIZER
|
|
#endif
|
|
#endif
|
|
|
|
#if defined(USING_THREAD_SANITIZER)
|
|
#define NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
|
|
extern "C" void __tsan_acquire(void* addr);
|
|
extern "C" void __tsan_release(void* addr);
|
|
#else
|
|
#define NO_SANITIZE_THREAD
|
|
#endif
|
|
|
|
#if defined(USING_THREAD_SANITIZER)
|
|
#define DO_IF_TSAN(CODE) CODE
|
|
#else
|
|
#define DO_IF_TSAN(CODE)
|
|
#endif
|
|
|
|
#if defined(USING_THREAD_SANITIZER)
|
|
#define DO_IF_NOT_TSAN(CODE)
|
|
#else
|
|
#define DO_IF_NOT_TSAN(CODE) CODE
|
|
#endif
|
|
|
|
// By default TSAN is enabled if this code is compiled under TSAN.
|
|
//
|
|
// Though in our AOT compiler we don't know whether the target AOT runtime will
|
|
// use TSAN or not, so we'll rely on the build rules telling us that
|
|
// information.
|
|
#if defined(USING_THREAD_SANITIZER) && !defined(DART_PRECOMPILER) && \
|
|
!defined(TARGET_USES_THREAD_SANITIZER)
|
|
#define TARGET_USES_THREAD_SANITIZER
|
|
#endif
|
|
|
|
#if defined(TARGET_USES_THREAD_SANITIZER)
|
|
constexpr bool kTargetUsesThreadSanitizer = true;
|
|
#else
|
|
constexpr bool kTargetUsesThreadSanitizer = false;
|
|
#endif
|
|
|
|
#endif // RUNTIME_PLATFORM_THREAD_SANITIZER_H_
|