Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
* 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.