From 06dd95bd8e5f12ffcf031d86fa9905b7d95ff78d Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Thu, 2 May 2024 23:31:48 +0000 Subject: [PATCH] [infra] Expand sanitizer test coverage. TEST=ci Change-Id: I5e7709572f3ea0a16925996be8ab903b6eccc0e1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365100 Reviewed-by: Siva Annamalai Commit-Queue: Ryan Macnak --- runtime/bin/ffi_test/ffi_test_functions.cc | 4 +- .../ffi_test/ffi_test_functions_vmspecific.cc | 1 + runtime/vm/compiler/backend/il.cc | 2 +- samples/ffi/samples_test.dart | 2 + tools/bots/test_matrix.json | 73 ++----------------- 5 files changed, 12 insertions(+), 70 deletions(-) diff --git a/runtime/bin/ffi_test/ffi_test_functions.cc b/runtime/bin/ffi_test/ffi_test_functions.cc index e43bafbc614..51f7d619393 100644 --- a/runtime/bin/ffi_test/ffi_test_functions.cc +++ b/runtime/bin/ffi_test/ffi_test_functions.cc @@ -9,9 +9,11 @@ #include #include +#include #include #include +#include #include #include #include @@ -898,7 +900,7 @@ DART_EXPORT void CallbackWithStruct(void (*f)(Struct8BytesNestedIntCopy)) { // Sanity test. DART_EXPORT intptr_t TestSimpleAddition(intptr_t (*add)(int, int)) { const intptr_t result = add(10, 20); - std::cout << "result " << result << "\n"; + printf("result %" PRIdPTR "\n", result); CHECK_EQ(result, 30); return 0; } diff --git a/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc b/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc index acb5980d4bc..f50c7f4c3e0 100644 --- a/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc +++ b/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc @@ -688,6 +688,7 @@ class PendingCall { *response_length_ = response_length; printf("C : Notify result ready.\n"); + std::unique_lock lock(mutex); notified = true; cv.notify_one(); } diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc index fa7891cd79c..b3a5995db06 100644 --- a/runtime/vm/compiler/backend/il.cc +++ b/runtime/vm/compiler/backend/il.cc @@ -2550,7 +2550,7 @@ Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) { break; case Token::kMOD: - if (std::abs(rhs) == 1) { + if ((rhs == -1) || (rhs == 1)) { return flow_graph->TryCreateConstantReplacementFor(this, Object::smi_zero()); } diff --git a/samples/ffi/samples_test.dart b/samples/ffi/samples_test.dart index 954aa9cd722..b53c5db8cda 100644 --- a/samples/ffi/samples_test.dart +++ b/samples/ffi/samples_test.dart @@ -5,6 +5,8 @@ // This file exercises the sample files so that they are tested. // // SharedObjects=ffi_test_dynamic_library ffi_test_functions +// Environment=MSAN_OPTIONS=handle_segv=0:detect_stack_use_after_return=1:allocator_may_return_null=1 +// Environment=TSAN_OPTIONS=handle_segv=0:detect_stack_use_after_return=1:allocator_may_return_null=1 import 'sample_ffi_bitfield.dart' as bitfield; import 'sample_ffi_data.dart' as data; diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json index 7491d843b2b..e66e6b75236 100644 --- a/tools/bots/test_matrix.json +++ b/tools/bots/test_matrix.json @@ -1250,6 +1250,7 @@ "builders": [ "vm-asan-linux-release-x64", "vm-msan-linux-release-x64", + "vm-tsan-linux-release-x64", "vm-ubsan-linux-release-x64" ], "meta": { @@ -1266,42 +1267,7 @@ { "name": "vm tests", "arguments": [ - "-nvm-${sanitizer}-${system}-${mode}-${arch}", - "corelib", - "ffi", - "language", - "lib", - "samples", - "standalone", - "utils", - "vm" - ], - "fileset": "vm", - "shards": 4 - } - ] - }, - { - "builders": [ - "vm-tsan-linux-release-x64" - ], - "meta": { - "description": "This configuration is used by the VM/JIT builders with sanitizers." - }, - "steps": [ - { - "name": "build dart", - "script": "tools/build.py", - "arguments": [ - "runtime" - ] - }, - { - "name": "vm tests", - "arguments": [ - "-nvm-${sanitizer}-${system}-${mode}-${arch}", - "vm", - "standalone" + "-nvm-${sanitizer}-${system}-${mode}-${arch}" ], "fileset": "vm", "shards": 8 @@ -1312,6 +1278,7 @@ "builders": [ "vm-aot-asan-linux-release-x64", "vm-aot-msan-linux-release-x64", + "vm-aot-tsan-linux-release-x64", "vm-aot-ubsan-linux-release-x64" ], "meta": { @@ -1329,40 +1296,10 @@ { "name": "vm tests", "arguments": [ - "-nvm-aot-${sanitizer}-${system}-${mode}-${arch}", - "vm", - "standalone" + "-nvm-aot-${sanitizer}-${system}-${mode}-${arch}" ], "fileset": "vm", - "shards": 4 - } - ] - }, - { - "builders": [ - "vm-aot-tsan-linux-release-x64" - ], - "meta": { - "description": "This configuration is used by the VM/AOT builders with sanitizers." - }, - "steps": [ - { - "name": "build dart", - "script": "tools/build.py", - "arguments": [ - "runtime", - "runtime_precompiled" - ] - }, - { - "name": "vm tests", - "arguments": [ - "-nvm-aot-${sanitizer}-${system}-${mode}-${arch}", - "vm", - "standalone" - ], - "fileset": "vm", - "shards": 8 + "shards": 12 } ] },