Add support for exceptions crossing native frames
authorJan Vorlicek <janvorli@microsoft.com>
Thu, 12 Mar 2015 02:04:01 +0000 (03:04 +0100)
committerJan Vorlicek <janvorli@microsoft.com>
Thu, 12 Mar 2015 19:57:27 +0000 (20:57 +0100)
commitf8f42933a46499aab91207385fca088185075a01
tree22f651073301044d6018f5b97c42939610f6148b
parent6d1715d68d8ca1f921534897828242bbcc4f00b6
Add support for exceptions crossing native frames

This change adds support for unwinding exceptions that cross native frames.
These are for example exceptions thrown / rethrown from catch blocks.
The exceptions are unwound in an interleaved manner in this case. First,
all managed frames upto the first native frame are unwound (both the first
and second pass), then the native frames are unwound by standard c++ exception
handling, then the next block of managed frames is unwound etc.
The change also implements RtlCaptureContext and changes the managed exception
handling to use it instead of the GetThreadContext. The difference is that the
RtlCaptureContext gets context of the caller while the GetThreadContext gets
a context somewhere deep in the PAL and so unwinding from such a context to the
first managed frame would be walking old stack frames that can already be corrupted.
As an additional change, I have fixed a problem that prevented unwinding of
assembler functions that use the PROLOG_WITH_TRANSITION_BLOCK macro.
The macro was using CFI annotation for the xmm registers and the libunwind
doesn't support that.
Moreover, the PAL_VirtualUnwind return status was not being checked in the
`Thread::VirtualUnwindToFirstManagedCallFrame`, so the failure resulted in an
infinite loop in there.
Finally, the `debug/di/amd64/floatconversion.S` was including the unixasmmacros.inc
using a relative path, now after I've moved it to a different place, I've removed
the relative path since the new path is in the include paths.
src/debug/di/amd64/floatconversion.S
src/pal/inc/unixasmmacros.inc [moved from src/vm/amd64/unixasmmacros.inc with 94% similarity]
src/pal/src/arch/i386/context2.S
src/pal/src/arch/i386/macros.inc [deleted file]
src/pal/src/debug/debug.cpp
src/vm/amd64/unixasmhelpers.S
src/vm/exceptionhandling.cpp
src/vm/exstatecommon.h
src/vm/stackwalk.cpp