Fix mono exception handler crashing on windows.
authorJoao Matos <joao.matos@xamarin.com>
Tue, 10 Jun 2014 16:03:30 +0000 (17:03 +0100)
committerJoao Matos <joao.matos@xamarin.com>
Tue, 10 Jun 2014 16:05:23 +0000 (17:05 +0100)
commitd8e44abb07c4e622edf933ebecb2c7ea793722a4
tree5ddf20db02c84c89ba630d9f744ee3c3442b3b4d
parentdcc7a89be1bee430f05fe0c06bc448d2c7aaaf51
Fix mono exception handler crashing on windows.

Here's the scenario that causes the crash:

Exception is fired, which invokes mono's vectored exception handler. It
is not an exception mono recognizes, so falls through to the default:
case in the exception handler. The problem is the return value has been
initialized to EXCEPTION_CONTINUE_EXECUTION. This causes SEH not to
process any other handlers, and just attempt to continue execution at
the point the exception was thrown.

The problem is much of windows internals will catch various exceptions
internally and handle them. So instead of the exception being handled,
we would just crash in the bowels of windows.

The solution is to set mono_win_chained_exception_needs_run to TRUE in
the default case - this is what the various exception handlers do if the
exception is not in JIT'd code. This causes the handler to return
EXCEPTION_CONTINUE_SEARCH, which causes SEH to search for the next
handler, and no crash is produced.

Both x86 and x64 had this bug, so I fixed it in both places.

Fix contributed by Steve Anichini.
mono/mini/exceptions-amd64.c
mono/mini/exceptions-x86.c