Skip to content

Commit 7708add

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm, compiler] Add --target-address-sanitizer.
The throw stub will need to be different under ASAN. TEST=ci Bug: #62095 Change-Id: Idd079fbab22d1c3f29c0d7e216998d54a521545c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464786 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 20085c0 commit 7708add

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

runtime/BUILD.gn

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ config("dart_precompiler_config") {
112112

113113
# In our GN build rules we'll always compile AOT compiler & AOT runtime in
114114
# the same mode (TSAN or non-TSAN).
115-
if (is_tsan) {
116-
defines += [ "TARGET_USES_THREAD_SANITIZER" ]
115+
if (is_asan && !is_win) {
116+
defines += [ "TARGET_USES_ADDRESS_SANITIZER" ]
117117
} else if (is_msan) {
118118
defines += [ "TARGET_USES_MEMORY_SANITIZER" ]
119+
} else if (is_tsan) {
120+
defines += [ "TARGET_USES_THREAD_SANITIZER" ]
119121
}
120122
}
121123

runtime/tests/vm/dart/sanitizer_compatibility_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ void checkExists(String path) {
2727
}
2828

2929
main() async {
30-
var sanitizer = find(Platform.executable, ["MSAN", "TSAN"]);
30+
var sanitizer = find(Platform.executable, ["ASAN", "MSAN", "TSAN"]);
3131
var mode = find(Platform.executable, ["Debug", "Release", "Product"]);
3232
var arch = find(Platform.executable, ["X64", "ARM64", "RISCV64"]);
3333
var out = find(Platform.executable, ["out", "xcodebuild"]);
3434
var targetFlag = {
35+
"ASAN": "--target_address_sanitizer",
3536
"MSAN": "--target_memory_sanitizer",
3637
"TSAN": "--target_thread_sanitizer",
3738
}[sanitizer]!;

runtime/vm/dart.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "vm/dart.h"
99

10-
#include "platform/thread_sanitizer.h"
1110
#include "platform/unwinding_records.h"
1211

1312
#include "vm/app_snapshot.h"
@@ -1083,8 +1082,9 @@ char* Dart::FeaturesString(IsolateGroup* isolate_group,
10831082
if (Snapshot::IncludesCode(kind)) {
10841083
VM_GLOBAL_FLAG_LIST(ADD_P, ADD_R, ADD_C, ADD_D);
10851084

1086-
ADD_FLAG(tsan, FLAG_target_thread_sanitizer)
1085+
ADD_FLAG(asan, FLAG_target_address_sanitizer)
10871086
ADD_FLAG(msan, FLAG_target_memory_sanitizer)
1087+
ADD_FLAG(tsan, FLAG_target_thread_sanitizer)
10881088
ADD_FLAG(shared_data, FLAG_experimental_shared_data)
10891089

10901090
if (kind == Snapshot::kFullJIT) {

runtime/vm/flag_list.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#ifndef RUNTIME_VM_FLAG_LIST_H_
66
#define RUNTIME_VM_FLAG_LIST_H_
77

8-
#include "platform/thread_sanitizer.h"
98
#include "vm/globals.h"
109

1110
// Don't use USING_PRODUCT outside of this file.

runtime/vm/flags.cc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ FLAG_LIST(PRODUCT_FLAG_MACRO,
7474
#undef DEBUG_FLAG_MACRO
7575

7676
#if defined(DART_PRECOMPILER)
77-
#if defined(TARGET_USES_THREAD_SANITIZER)
78-
constexpr bool kDefaultTargetThreadSanitizer = true;
77+
#if defined(TARGET_USES_ADDRESS_SANITIZER)
78+
constexpr bool kDefaultTargetAddressSanitizer = true;
7979
#else
80-
constexpr bool kDefaultTargetThreadSanitizer = false;
80+
constexpr bool kDefaultTargetAddressSanitizer = false;
8181
#endif
8282
DEFINE_FLAG(bool,
83-
target_thread_sanitizer,
84-
kDefaultTargetThreadSanitizer,
85-
"Generate Dart code compatible with Thread Sanitizer");
83+
target_address_sanitizer,
84+
kDefaultTargetAddressSanitizer,
85+
"Generate Dart code compatible with Address Sanitizer");
8686
#if defined(TARGET_USES_MEMORY_SANITIZER)
8787
constexpr bool kDefaultTargetMemorySanitizer = true;
8888
#else
@@ -92,6 +92,16 @@ DEFINE_FLAG(bool,
9292
target_memory_sanitizer,
9393
kDefaultTargetMemorySanitizer,
9494
"Generate Dart code compatible with Memory Sanitizer");
95+
96+
#if defined(TARGET_USES_THREAD_SANITIZER)
97+
constexpr bool kDefaultTargetThreadSanitizer = true;
98+
#else
99+
constexpr bool kDefaultTargetThreadSanitizer = false;
100+
#endif
101+
DEFINE_FLAG(bool,
102+
target_thread_sanitizer,
103+
kDefaultTargetThreadSanitizer,
104+
"Generate Dart code compatible with Thread Sanitizer");
95105
#endif
96106

97107
static bool IsMainOrDevChannel() {

runtime/vm/flags.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef RUNTIME_VM_FLAGS_H_
66
#define RUNTIME_VM_FLAGS_H_
77

8+
#include "platform/address_sanitizer.h"
89
#include "platform/assert.h"
910
#include "platform/memory_sanitizer.h"
1011
#include "platform/thread_sanitizer.h"
@@ -162,19 +163,25 @@ FLAG_LIST(PRODUCT_FLAG_MACRO,
162163
#undef PRECOMPILE_FLAG_MACRO
163164

164165
#if defined(DART_PRECOMPILER)
165-
DECLARE_FLAG(bool, target_thread_sanitizer);
166+
DECLARE_FLAG(bool, target_address_sanitizer);
166167
DECLARE_FLAG(bool, target_memory_sanitizer);
168+
DECLARE_FLAG(bool, target_thread_sanitizer);
167169
#else
168-
#if defined(USING_THREAD_SANITIZER)
169-
constexpr bool FLAG_target_thread_sanitizer = true;
170+
#if defined(USING_ADDRESS_SANITIZER)
171+
constexpr bool FLAG_target_address_sanitizer = true;
170172
#else
171-
constexpr bool FLAG_target_thread_sanitizer = false;
173+
constexpr bool FLAG_target_address_sanitizer = false;
172174
#endif
173175
#if defined(USING_MEMORY_SANITIZER)
174176
constexpr bool FLAG_target_memory_sanitizer = true;
175177
#else
176178
constexpr bool FLAG_target_memory_sanitizer = false;
177179
#endif
180+
#if defined(USING_THREAD_SANITIZER)
181+
constexpr bool FLAG_target_thread_sanitizer = true;
182+
#else
183+
constexpr bool FLAG_target_thread_sanitizer = false;
184+
#endif
178185
#endif
179186

180187
DECLARE_FLAG(bool, experimental_shared_data);

0 commit comments

Comments
 (0)