From ecbbf4a141f5d50e220d574d32dfdcc0ed02714a Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 23 Apr 2025 14:46:10 -0700 Subject: [PATCH] [test] Bypass global destructors when exiting without shutting down the VM. Running global destructors can interfer with VM code running on other threads, including causing MSAN to flag accesses as using uninitialized memory. TEST=msan, ffi/vmspecific_function_callbacks_exit_test Change-Id: Ia9a7223ecc81690a2047e5936b9a138fff620ad1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424241 Commit-Queue: Ryan Macnak Reviewed-by: Alexander Aprelev --- runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc b/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc index c8725fc5e7b..6780c8582a8 100644 --- a/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc +++ b/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc @@ -231,10 +231,14 @@ intptr_t ExpectAbort(void (*fn)()) { } else { // Caught the setjmp. sigaction(SIGABRT, &old_action, nullptr); - exit(0); + + // _exit not exit. Because we're not doing a clean VM shutdown, we need to + // avoid running global destructors while other isolates and background + // compilers are still running. + _exit(0); } fprintf(stderr, "Expected abort!!!\n"); - exit(1); + _exit(1); } void* TestCallbackOnThreadOutsideIsolate(void* parameter) {