[vm, ffi] Better handle errors that are not unhandled exceptions during FFI callbacks.

Before this change, an error reaching an FFI callback would attempt to execute the normal invocation stub from the beginning in the FFI callback's frame, which quickly crashes. After this change, the runtime recognizes this marker use of the invocation stub and returns to the FFI callback function instead.

TEST=ffi/unwind
Bug: https://github.com/dart-lang/sdk/issues/39487
Change-Id: I477cfcfc236e6cf518ebfe52860ba49e466ebf8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409562
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2025-02-19 09:40:34 -08:00
committed by Commit Queue
parent a864586f3c
commit cb59df7acf
15 changed files with 260 additions and 60 deletions
+5
View File
@@ -229,6 +229,11 @@ void Thread::set_active_exception(const Object& value) {
active_exception_ = value.ptr();
}
void Thread::set_active_exception(LocalHandle* value) {
active_exception_ = ObjectPtr(reinterpret_cast<uword>(value));
ASSERT(active_exception_.IsImmediateObject()); // GC won't try to visit this.
}
void Thread::set_active_stacktrace(const Object& value) {
active_stacktrace_ = value.ptr();
}