Bug 37273 - Exceptions caught in incorrect catch blocks on LLVM builds
Summary: Exceptions caught in incorrect catch blocks on LLVM builds
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler (show other bugs)
Version: XI 9.4 (iOS 9.2)
Hardware: PC Mac OS
: --- normal
Target Milestone: C6SR2
Assignee: Zoltan Varga
: 37744 (view as bug list)
Depends on:
Reported: 2015-12-23 23:51 UTC by Cody Beyer (MSFT)
Modified: 2016-03-03 16:37 UTC (History)
10 users (show)

See Also:
Tags: BZRC6S1_C5SR5S1
Is this bug a regression?: ---
Last known good build:


Description Cody Beyer (MSFT) 2015-12-23 23:51:12 UTC
### Description 

This is most likely a Mono bug, however I wanted to file it against the most external product for engineering to review 

The following sample demonstrates an issue where the incorrect catch block will handle an exception when LLVM is used

### Sample


### Error Details


### Steps to Reproduce

1. Download Sample
2. Ensure LLVM is enabled, and device is targeted
3. Run on device
4. Review device log in Xcode

### Expected Results

Handled as demonstrated in the first block of linked gist

### Actual Results

Handled as demonstrated in 2nd block of linked gist

### Versions

=== Xamarin Studio ===

Version 5.10.2 (build 49)
Installation UUID: 898b546d-da31-47aa-aa48-67c373406277
	Mono 4.2.2 (explicit/7b87787)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402020010

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 78c6cd3
Branch: master
Build date: 2015-12-17 18:29:42-0500

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 510020049
Git revision: deed4cd240ff3611c8742bbc62296e207f46173d
Build date: 2015-12-17 11:13:36-05
Xamarin addins: 8bd975e7b465f6fe812b64d736f3b7e8c1a79a3e
Build lane: monodevelop-lion-cycle6-c6sr1

=== Operating System ===

Mac OS X 10.11.2
Darwin beyerstudios.local 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Comment 1 chorsfield 2015-12-28 21:22:43 UTC
This regressed with Xamarin.IOS. It was working fine on
This causes major logic issues in basic try \ catch code blocks within code.
Comment 2 Zoltan Varga 2016-01-02 02:49:00 UTC
Reduced testcase:
 private static Task ATask(Task taskFunction)
	 return Task.Run(async () => {
			 try {
				 await taskFunction;
			 } catch (DivideByZeroException ex) {
				 Console.WriteLine ("FAIL: " + ex);
	public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		try {
			Task t = new Task (delegate () { throw new Exception(); });
			t.Start ();
			Task task = ATask(t);
		} catch (Exception ex) {
			Console.WriteLine ("OK.");
		return true;
Comment 3 Zoltan Varga 2016-01-02 03:12:04 UTC
Should be fixed by mono 81e1e072c89873243a6c4cc9263ddf2c8658f312.

This could be backported to a service release.
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2016-01-07 18:14:34 UTC
## Regression status: regression in Cycle 6

I can confirm the result from Comment 1 using the test case from Comment 2: this bug is a regression between Cycle 5 SR 5 and Cycle 6.

BAD:  Xamarin.iOS (78c6cd3)
BAD:  Xamarin.iOS (3c0ec35)
GOOD: Xamarin.iOS (1f068b4)
Comment 7 Zoltan Varga 2016-01-18 15:57:45 UTC
*** Bug 37744 has been marked as a duplicate of this bug. ***
Comment 8 Grigory (Playtika) 2016-01-18 16:00:47 UTC
When will it be public released ?
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2016-01-18 18:35:36 UTC
The timeline for the "C6SR2" ("Cycle 6 – Service Release 2") target milestone of this bug is currently under planning. There should be more news about the timeline once the current Alpha "Service Release 1" is promoted to stable (tentatively within the next couple of weeks).

If more discussion on possible release dates is desired, please get in touch via a "Business & Enterprise Support" [1] email.

[1] https://xamarin.com/support
Comment 11 GouriKumari 2016-03-03 16:37:24 UTC
Based on comment #10, I am closing this bug as verified fixed.

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

Note You need to log in before you can comment on or make changes to this bug.