[vm] Don't rely on UB in OSThread::GetCurrentStackPointer.

TEST=ci
Change-Id: Ic0fd502148ed4666140849f9d6e2af3006818b03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350694
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2024-02-21 22:13:09 +00:00 committed by Commit Queue
parent 1dba9e917c
commit 639f6735a8

View file

@ -128,16 +128,15 @@ void OSThread::SetName(const char* name) {
#endif // defined(SUPPORT_TIMELINE)
}
// Disable AddressSanitizer and SafeStack transformation on this function. In
// particular, taking the address of a local gives an address on the stack
// instead of an address in the shadow memory (AddressSanitizer) or the safe
// stack (SafeStack).
NO_SANITIZE_ADDRESS
NO_SANITIZE_SAFE_STACK
DART_NOINLINE
uword OSThread::GetCurrentStackPointer() {
uword stack_allocated_local = reinterpret_cast<uword>(&stack_allocated_local);
return stack_allocated_local;
#ifdef _MSC_VER
return reinterpret_cast<uword>(_AddressOfReturnAddress());
#elif __GNUC__
return reinterpret_cast<uword>(__builtin_frame_address(0));
#else
#error Unimplemented
#endif
}
#if !defined(PRODUCT)