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 10278 [details]
An exception thrown in a modal window causes a native crash.
## Steps to reproduce:
1. Open attached test project.
2. Launch App
3. Click the Push Me button
4. Click the Crash button
Expected result: App will not crash with a native crash
Actual result: App crashes with native crash.
## Native stacktrace:
I tested this on Xam.Mac 1.10, 1.12, and 1.13. I was able to reproduce the native crash with all three versions.
## Version info:
=== Xamarin Studio ===
Version 5.8 (build 443)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Mono 3.12.1 ((detached/b7764aa)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312010000
=== Apple Developer Tools ===
Xcode 6.2 (6776)
=== Xamarin.Mac ===
Version: 188.8.131.52 (Business Edition)
=== Xamarin.Android ===
Version: 184.108.40.206 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
4.0 (API level 14)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
=== Xamarin Android Player ===
Version: Unknown version
Location: /Applications/Xamarin Android Player.app
=== Xamarin.iOS ===
Version: 220.127.116.11 (Business Edition)
Build date: 2015-03-10 02:20:32-0400
=== Build Information ===
Release ID: 508000443
Git revision: 73883239470cbe8e261c94d95f7c3d0452fd393b
Build date: 2015-03-10 07:22:51-04
Xamarin addins: a2ff7b617f09d9c45d8bbf3d010b5db0d7d36100
=== Operating System ===
Mac OS X 10.10.2
Darwin Jons-iMac.local 14.1.0 Darwin Kernel Version 14.1.0
Thu Feb 26 19:26:47 PST 2015
I can reproduce this as well.
We are looking into ways of improving exception handling in the future, but sometime when you "leak" a c# exception through objective-c strange things can occur.
Until we can improve this, the obvious, but rather annoying, solution for this is "don't do that".
I've spoken with some other member of my team, and the short answer is that you never should let a C# exception "escape" to the calling objective-c. If you do, the results are undefined but generally involve crashing.
Without getting too far into the technical details, the issue is that we can't just convert the c# exception to an objective-c one, as this would cause performance issues and objective-c exceptions really aren't much better.
I'm going to work with documentation to try to get this documented better.
Sorry, I'm sure that wasn't the solution you were hoping for when you filed this bug.
https://github.com/praeclarum/StopCrashing might be of interest as well.
I'm really disappointed with your answer. Basically you are saying to me don't code bugs and you are going to be ok.
I mentioned in my email to the support that my real case was more complex then the simplified test project I sent you.
The crash was happening randomly in a method of a NSMenuDelegate we created. The problem has been found by luck and it's now fixed.
My complain is about having more information to debug those issue. The the app is crashing and the only thing you got his a cryptic Native Crash that doesn't contain any hint on what part of your code is throwing it.
The StopCrashing script worked great and it will helps us prevent some future crash but there will be situation where it will fail.
I wish there was a way for you to give us more information when the app crash.
I'm sorry with the fact that you are disappointed with the answer I gave. I'll try to give you more color on specifically why what you are asking for is a very difficult problem to solve in a performant manor, and that it isn't any different than what we tell iOS customers.
Nobody here believes that having managed exceptions that bubble through unmanaged code be undefined behavior (and thus bad) is the ideal solution. In general, we do everything we can to bubble up useful information for both native and managed crashes to help you solve your issues quickly.
Without getting too bogged down with the technical reasons why, setting up the infrastructure to catch managed exceptions at every managed/native boundary is non-trivially expensive and there are a _lot_ of transitions that happen in many common operations. Many operations, specifically ones that involve the UI thread must finish quickly or your app will stutter and have unacceptable performance characteristics. Many of those callbacks do very simple things that rarely have the possibility of throwing, so this overhead would both be expensive and unnecessary in those cases.
Thus, we'd don't set up those try / catches for you. For places where you code does non-trivial things (beyond say returning a booleans or simple math), you can try catch yourself.
Hope that helps you understand the answer, even if it wasn't what you were hoping for.
-- Chris H