Make PAL_SEHException smaller (#6267)
authorJan Vorlicek <janvorli@microsoft.com>
Wed, 20 Jul 2016 12:21:08 +0000 (14:21 +0200)
committerGitHub <noreply@github.com>
Wed, 20 Jul 2016 12:21:08 +0000 (14:21 +0200)
commit03250d34da85f23df0a8f7ad1c8b3760e0b73b1f
tree089a7d6eb08b60ca0b80d764ec5acc998a4ea234
parentf3317125ebf10f9d949b5460cbdff8153748346f
Make PAL_SEHException smaller (#6267)

The PAL_SEHException is quite large due to the fact that it contains context
and exception records. This causes a problem when we try to throw it and
system gets out of memory. The C++ runtime can throw exceptions even in that
case, but only if they are smaller than certain threshold. So in our case,
it just aborts the process.

This change separates the context and exception records from the exception,
which ensures that the above mentioned mechanism in the C++ runtime can
kick in and the exception can be thrown even when malloc fails to allocate
it.

I have also modified HandleHardwareException to return BOOL indicating whether
the execution should continue at the possibly modified exception context
instead of using RtlRestoreContext. In that case, we return all the way back
to the signal handler, update the ucontext in there and return from it.
src/pal/inc/pal.h
src/pal/src/exception/machexception.cpp
src/pal/src/exception/seh-unwind.cpp
src/pal/src/exception/seh.cpp
src/pal/src/exception/signal.cpp
src/pal/src/include/pal/seh.hpp
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.cpp
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.cpp
src/vm/exceptionhandling.cpp
src/vm/exceptionhandling.h
src/vm/exceptmacros.h