Fix Unix exception handling in finalizers
authorJan Vorlicek <janvorli@microsoft.com>
Mon, 7 Mar 2016 22:09:45 +0000 (23:09 +0100)
committerJan Vorlicek <janvorli@microsoft.com>
Tue, 8 Mar 2016 17:08:55 +0000 (18:08 +0100)
commit7f5d0a5b0546edf283e855d3ae95283485d180ea
tree6636a1e2373a885231e7e7e85c0484874058b1d6
parente454121ee731e35de9244596c4a5cd1563d455fe
Fix Unix exception handling in finalizers

When unhandled exception happens in a finalizer thread and there are
no managed frames till the bottom of the stack,
the Thread::VirtualUnwindToFirstManagedCallFrame then fails fast.
The fix is to make the Thread::VirtualUnwindToFirstManagedCallFrame to
return even in case no managed frame is called, which is indicated by
its returning 0 as the resulting IP address. The DispatchManagedException
then checks that and rethrows the exception instead of trying to call
UnwindManagedExceptionPass1.
I have also added INSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP to the
FinalizerThread::FinalizerThreadStart so that the unhandled exception
doesn't escape the stack.
And I also needed to modify the UNINSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP
to detect case when the unhandled exception filter was already executed so
that it doesn't double-report the unhandled exception.
src/vm/exceptionhandling.cpp
src/vm/exceptmacros.h
src/vm/finalizerthread.cpp
src/vm/stackwalk.cpp