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
Developer Community or GitHub 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.
Created attachment 24198 [details]
test case (for desktop)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture (ex).Throw () doesn't work correctly when called in a reverse pinvoke.
The bug goes like this:
* System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture (ex) will capture the exception information
* .Throw () will throw the exception
* The reverse-invoke will capture the exception, and throw (not rethrow) it.
* Throwing the exception (instead of re throwing it) will clear the stack trace.
* Mono will then try to setup the stack again, and set MonoException.trace_ips to NULL (because there are no managed frames on the stack): https://github.com/mono/mono/blob/9ba3fa0ba37c3b11b7129c3092a379711fd128e4/mono/mini/mini-exceptions.c#L1519
* The native MonoException.trace_ips field maps to the managed System.Exception._stackTrace
* System.Exception.GetStackTrace has different behavior whether the _stackTrace field is null or not: https://github.com/mono/mono/blob/9ba3fa0ba37c3b11b7129c3092a379711fd128e4/mcs/class/referencesource/mscorlib/system/exception.cs#L382. If the _stackTrace field is null, then a remoting stack trace is returned, and since that's also obviously null (no remoting in the attached test case), Exception.GetStackTrace returns null.
* As a result, the StackTrace for the thrown exception is null, even if System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture was used to (attempt to) capture it.
* Set MonoException.trace_ips to an empty array instead of NULL if there are no managed frames: https://gist.github.com/rolfbjarne/915177f818e57c02fb2b40dc691740dc
This is a spin-off of bug #58352.
This is a mono regression, for the attached test case:
> Mono JIT compiler version 184.108.40.206 (2017-02/9667aa6 Fri May 5 09:12:57 EDT 2017)
> Mono JIT compiler version 220.127.116.11 (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)
However it seems like it's been failing a while for XI, I tested this as far back as XI 10.0 ("mtouch 10.0.1.10 (cycle8-sr0-xi: ad1cd42)") using the test case from bug #58352, and it failed in all versions.
Moving to 15.5 as this will not make 15.4
Got fixed by the fix for: