[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 <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Ryan Macnak
2025-04-23 14:46:10 -07:00
committed by Commit Queue
parent 45d187e0ef
commit ecbbf4a141
@@ -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) {