* Use test case from bug #58780.
* Run "make plainthrow"
The problem is that there's an implicit try/catch handler in the native-to-managed wrapper, and that try/catch handler throws the exception again (instead of rethrowing it, which would preserve the stack trace): https://github.com/mono/mono/blob/83020f1270ecbdfcbdf02cee687beadcba7c89ae/mono/metadata/marshal.c#L12369
Implementing a mono_reraise_exception and using that instead fixes the bug: https://gist.github.com/rolfbjarne/79ef3ca886743b4811f09b182609be6c
> Mono JIT compiler version 18.104.22.168 (2017-02/9667aa6 Fri May 5 09:12:57 EDT 2017)
> Mono JIT compiler version 22.214.171.124 (2017-04/161f032 Wed Jul 26 15:23:07 EDT 2017)
> Mono JIT compiler version 5.7.0 (master/b89b696e71f Tue Aug 15 19:38:06 CEST 2017)
This is fixed on master with https://github.com/mono/mono/commit/ab90246c67d5d12ec9fabae5e490a05db2c0be6b
It is backported to 5.4 and 5.6 with https://github.com/mono/mono/pull/5394 and https://github.com/mono/mono/pull/5395 respectively.