Fix crash in mono mini exceptions.exe regression test on win x64.
authorlateralusX <lateralusx.github@gmail.com>
Thu, 7 Jul 2016 15:24:49 +0000 (17:24 +0200)
committerlateralusX <lateralusx.github@gmail.com>
Thu, 7 Jul 2016 15:24:49 +0000 (17:24 +0200)
commit87afbc44229e22db3b9784766967d23de8d83283
tree19493bb7134e2804d3838082a4f11cc3436e9a0d
parent7fa8d071253bba57ec253623b36a6c08f2c444d2
Fix crash in mono mini exceptions.exe regression test on win x64.

Exceptions.exe regression test started to fail on win x64 release builds.
Turns out that the Visual Studio C compiler picked a different optimization
for release builds (due to a change of library type that uses a different default optimization level)
using RSI register in native code calling into JIT:ed code. If the JIT:ed code used reflection
and exceptions, that triggers InternalInvoke and lmf_filter, the code only
stored System V x64 non-volatile registers in the unwind information. On Windows,
RSI is also a non-volatile register (RDI as well) that needs to be preserved and
since the code didn’t include those in the unwind information, the correct RSI value
was not restored during the unwind. Once the control was handled back to the native
code it dereferenced RSI (that was set to 0) and crashed.

The fix is to make sure we store all non-volatile registers on x64 Windows
when we save an lmf so the unwind code can restore them when unwinding through
the lmf.
mono/mini/mini-amd64.c