[runtime] Setup stack trace for use in exception filters too (#8241)
commit963f94474eb47ab7adcf802c678a10751136d602
authorAnkit Jain <radical@gmail.com>
Tue, 24 Apr 2018 18:20:03 +0000 (24 14:20 -0400)
committerLudovic Henry <luhenry@microsoft.com>
Tue, 24 Apr 2018 18:20:03 +0000 (24 14:20 -0400)
tree93335d8fd056adb47d2d7b10e6e205d599d1051e
parentbaef8453a859930928af455c3124e9210ff77182
[runtime] Setup stack trace for use in exception filters too (#8241)

If we have
`catch (Exception e) when (SomeMethod (e))`

.. then the exception object received in `SomeMethod` has an empty
trace. This is because in `handle_exception_first_pass` we populate the
trace in `MonoException` object only at the "end":

- filter returns TRUE
- exception caught
- unhandled exception

But if we have a filter then the trace at that point needs to be
accessible. And if the filter fails then as we unwind more frames, the
earlier frames (`trace_ips`) need to be retained to get the correct full
trace.

`dynamic_methods` needs to be handled similarly and in
`setup_stack_trace` we need to add to the existing `dynamic_methods` in
the MonoException object.

Fixes https://github.com/mono/mono/issues/7649 .
mono/mini/mini-exceptions.c
mono/tests/Makefile.am
mono/tests/exception20.cs [new file with mode: 0644]