Bug 52375 - Exceptions in UIView.Animate delegates lose stacktrace
Summary: Exceptions in UIView.Animate delegates lose stacktrace
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime (show other bugs)
Version: XI 10.3 (iOS 10.2)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Manuel de la Peña [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-02-08 05:17 UTC by Dan
Modified: 2018-03-21 17:13 UTC (History)
3 users (show)

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


Attachments
Sample (26.50 KB, application/zip)
2017-02-08 05:17 UTC, Dan
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED FIXED

Description Dan 2017-02-08 05:17:35 UTC
Created attachment 19754 [details]
Sample

Exceptions thrown in the completion delegates for UIView.Animate do not seem to be handled properly by the runtime or debugger.  In particular, it is observed that (1) the debugger breaks on the UIApplication.Main method, rather than the actual site of the exception, and (2) any stack trace determining where the exception was triggered is lost.

Attached is a sample solution w/ a single iOS project demonstrating the issue.  This solution was created via "New Solution... => iOS App => Single View App" and making the necessary code changes to ApplicationDelegate.cs and ViewController.cs.  By selectively commenting-uncommenting cases in the ViewController.cs class, one can reproduce the behavior described above.  The observed stack traces are included in the comments.

It is expected that exceptions which are thrown from delegates contain the correct stack trace to the throw-site of the exception.

Additional notes: this same type of stack trace (one that claims to fire from UIApplication.Main) is observed as well in crash reporting tools for a separate project, suggesting it is not simply an issue w/ the debugger itself.

Project was built on OS X w/:
  Xamarin Studio Community 6.1.5
  Xamarin.iOS 10.3.1.8
Comment 1 Manuel de la Peña [MSFT] 2017-02-08 09:35:08 UTC
Confirming the bug with:

=== Xamarin Studio Community ===

Version 6.1.5 (build 0)
Installation UUID: 01060673-5bee-4cf4-a4c2-5e36a18d39a2
Runtime:
	Mono 4.9.0 (master/60b660d) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 409000613

=== NuGet ===

Version: 3.4.3.0

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.Mac ===

Version: 2.10.0.120 (Xamarin Studio Community)

=== Xamarin.Android ===

Version: 7.0.2.42 (Xamarin Studio Community)
Android SDK: /Users/mandel/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		6.0   (API level 23)

SDK Tools Version: 25.1.6
SDK Platform Tools Version: 24.0.0
SDK Build Tools Version: 23.0.2

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)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

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

=== Xamarin.iOS ===

Version: 10.3.1.8 (Xamarin Studio Community)
Hash: 7beaef4
Branch: cycle8-xi
Build date: 2016-12-20 02:58:14-0500

=== Xamarin Inspector ===

Version: 1.0.0.0
Hash: 1f3067d
Branch: master
Build date: 11/15/2016 10:13:59 PM

=== Build Information ===

Release ID: 601050000
Git revision: 7494718e127af9eaec45a3bd6282d3da927488bd
Build date: 2017-01-17 10:31:01-05
Xamarin addins: c92d0626d347aaa02839689eaac2961d24c9f446
Build lane: monodevelop-lion-cycle8

=== Operating System ===

Mac OS X 10.12.3
Darwin MacBook-Pro.local 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Addin Maker 1.3.2
StyleCop Support 1.0.1.9
Xamarin Inspector 1.0.0.0
Manifest.addin 0.0.0.0
Comment 2 Rolf Bjarne Kvinge [MSFT] 2017-02-08 10:41:55 UTC
@Manuel, I believe this is fixed in Cycle9, can you try?
Comment 3 Manuel de la Peña [MSFT] 2017-02-08 10:46:46 UTC
@Rolf, sure, will check c9 and master
Comment 4 Manuel de la Peña [MSFT] 2018-03-21 17:13:18 UTC
After testing against master I have the following results:

Case 2 trace:

System.Exception: TEST
  at testexception.ViewController.Test () [0x00001] in /Users/mandel/Downloads/testexception/testexception/ViewController.cs:52
  at UIKit.UIView+<>c__DisplayClass11_0.<Animate>b__0 (System.Boolean x) [0x00008] in /Users/mandel/Xamarin/macios/master/xamarin-macios/src/UIKit/UIView.cs:127
  at ObjCRuntime.Trampolines+SDUICompletionHandler.Invoke (System.IntPtr block, System.Boolean finished) [0x00016] in /Users/mandel/Xamarin/macios/master/xamarin-macios/src/build/ios/native/ObjCRuntime/Trampolines.g.cs:32754
  at at (wrapper native-to-managed) ObjCRuntime.Trampolines+SDUICompletionHandler.Invoke(intptr,int)
  at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/mandel/Xamarin/macios/master/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Users/mandel/Xamarin/macios/master/xamarin-macios/src/UIKit/UIApplication.cs:63
  at testexception.Application.Main (System.String[] args) [0x00001] in /Users/mandel/Downloads/testexception/testexception/Main.cs:12

Which is correct.

Case 3:

System.Exception: TEST2
  at testexception.ViewController.Test2 (System.Boolean isFinished) [0x00001] in /Users/mandel/Downloads/testexception/testexception/ViewController.cs:57
  at ObjCRuntime.Trampolines+SDUICompletionHandler.Invoke (System.IntPtr block, System.Boolean finished) [0x00016] in /Users/mandel/Xamarin/macios/master/xamarin-macios/src/build/ios/native/ObjCRuntime/Trampolines.g.cs:32754
  at at (wrapper native-to-managed) ObjCRuntime.Trampolines+SDUICompletionHandler.Invoke(intptr,int)
  at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/mandel/Xamarin/macios/master/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Users/mandel/Xamarin/macios/master/xamarin-macios/src/UIKit/UIApplication.cs:63
  at testexception.Application.Main (System.String[] args) [0x00001] in /Users/mandel/Downloads/testexception/testexception/Main.cs:12

Same as with the other case, works correctly pointing to de correct issue.

Closing bug as fixed.