This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 45116 - Debugger fail to break on XF and iOS
Summary: Debugger fail to break on XF and iOS
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger (show other bugs)
Version: XI 9.10 (C8)
Hardware: PC Windows
: --- critical
Target Milestone: (C9)
Assignee: Rolf Bjarne Kvinge
URL:
Depends on:
Blocks:
 
Reported: 2016-10-06 13:56 UTC by Axel
Modified: 2016-12-05 16:55 UTC (History)
14 users (show)

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


Attachments
Repro project (162.14 KB, application/x-zip-compressed)
2016-10-06 13:59 UTC, Axel
Details
verbose logs from reproduction (11.85 KB, application/x-zip-compressed)
2016-10-10 20:22 UTC, Kyle White
Details

Description Axel 2016-10-06 13:56:01 UTC
# Steps to reproduce
See attached project

# Expected behavior
When an exception is thrown, debugger breaks where it has been thrown, and stacktrace in the output windows shows the correct location

# Actual behavior
Debbuger always breaks in  UIApplication.Main(args, null, "AppDelegate");
and stackstrace in the output windows is always : 
Unhandled Exception: 
System.DivideByZeroException: Attempted to divide by zero.
  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/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at Testbug44567.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\axelc\Documents\Visual Studio 2015\Projects\Testbug44567\Testbug44567\Testbug44567.iOS\Main.cs:17 
2016-10-06 15:47:17.822 Testbug44567.iOS[3514:24988] Unhandled managed exception:
Attempted to divide by zero. (System.DivideByZeroException)
  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/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at Testbug44567.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\axelc\Documents\Visual Studio 2015\Projects\Testbug44567\Testbug44567\Testbug44567.iOS\Main.cs:17 

# Supplemental info (logs, images, videos)
http://forums.xamarin.com/discussion/79547/debugger-fail-to-break-where-exception-are-thrown-in-ios-project-xf
http://forums.xamarin.com/discussion/79816/xamarin-ios-app-crashes-in-simulator-at-startup-since-ios-10

# Test environment (full version information)
Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586

Version installée : Enterprise

Outils d'architecture et de modélisation   00322-80000-00000-AA334
Outils d'architecture et de modélisation Microsoft
    
UML® et Unified Modeling Language™ sont des marques ou des marques déposées de Object Management Group, Inc. aux États-Unis d'Amérique et dans d'autres pays.

Visual Basic 2015   00322-80000-00000-AA334
Microsoft Visual Basic 2015

Visual C# 2015   00322-80000-00000-AA334
Microsoft Visual C# 2015

Visual C++ 2015   00322-80000-00000-AA334
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - FRA   00322-80000-00000-AA334
Windows Phone SDK 8.0 - FRA

ASP.NET and Web Tools 2015.1   14.1.20907.0
ASP.NET and Web Tools 2015.1

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.9.1   14.0.20622.0
Azure App Service Tools v2.9.1

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.0.6000.0
Microsoft Azure Data Lake Tools for Visual Studio

Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.

Common Azure Tools   1.8
Fournit des services courants utilisables par Microsoft Azure Mobile Services et Microsoft Azure Tools.

Gestionnaire de package NuGet   3.5.0
Gestionnaire de package NuGet dans Visual Studio. Pour plus d'informations sur NuGet, consultez la page http://docs.nuget.org/.

GitHub.VisualStudio   1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

Microsoft .NET Core Tools (Preview 2)   14.1.20907.0
Microsoft .NET Core Tools (Preview 2)

Microsoft Azure HDInsight HQL Service   2.0.6000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   2.0.6000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Tools   2.9
Microsoft Azure Tools pour Microsoft Visual Studio 2015 - v2.9.40701.9

NuProjPackage   1.0
NuGet Package Project System

NuspecPackager   1.3
Provides ability to pack nuspec files from the Solution Explorer context menu

Outils Microsoft Azure Mobile Services   1.4
Outils Microsoft Azure Mobile Services

Package Outils Application Insights pour Visual Studio   7.8.00927.1
Outils Application Insights pour Visual Studio

PreEmptive Analytics Visualizer   1.2
Extension Microsoft Visual Studio permettant de visualiser des résumés agrégés à partir du produit PreEmptive Analytics.

Service de langage JavaScript   2.0
Service de langage JavaScript

SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools

Système de projet JavaScript   2.0
Système de projet JavaScript

TestCommand Extension   1.0
TestCommand Visual Studio Extension Detailed Info

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   1.8.36.0
Outils TypeScript pour Visual Studio

Visual Studio Tools pour Apache Cordova   Update 10
Visual Studio Tools pour Apache Cordova

Visual Studio Tools pour les applications Windows universelles   14.0.25420.01
Visual Studio Tools pour les applications Windows universelles vous permet de créer une expérience d'application universelle unique que vous pouvez retrouver sur tous les appareils exécutant Windows 10 : téléphones, tablettes, PC, etc. Il inclut le Kit de développement logiciel (SDK) Microsoft Windows 10.

Xamarin   4.2.0.703 (3b7df6f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.0.1.3 (96c7ba6)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.0.1.10 (ad1cd42)
Visual Studio extension to enable development for Xamarin.iOS.
------------------------------------------
Mac OS 10.11.6
XCode 8
Comment 1 Axel 2016-10-06 13:59:07 UTC
Created attachment 17906 [details]
Repro project
Comment 3 Claudio Redi 2016-10-06 14:02:47 UTC
Same is happening to me since upgraded Xamarin studio to 6.0
Comment 4 Claudio Redi 2016-10-10 18:20:01 UTC
Is there any news about this? Any person in Xamarin team was able to recreate it? It makes very difficult to troubleshoot crashes in app since stacktrace is totally irrelevant.

Thanks
Comment 5 Kyle White 2016-10-10 20:22:19 UTC
Created attachment 17966 [details]
verbose logs from reproduction
Comment 6 Kyle White 2016-10-10 20:30:31 UTC
XS on Mac does the same thing.

Logs from XS repro.. https://gist.github.com/kdubau/a526247eec816f914d73b23f9f03abf4
Comment 7 Jose Gallardo 2016-10-18 17:35:27 UTC
Moving to `Forms` for visibility from the x.Forms team.
Thanks
Comment 8 Robby Groot 2016-10-19 11:35:24 UTC
This issue is not limited to Xamarin.Forms only, though. I've had this issue happen in a Xamarin.iOS project as well.
Comment 9 Thomas Guzman 2016-10-20 13:21:48 UTC
I can confirm I have this problem too on a Xamarin.iOS project
But only when debugging in Simulator, when debugging on device, stack trace is correctly set

Is there any other workaround for now ?
This is pretty urgent...
Comment 10 Ian Toal 2016-10-25 13:25:41 UTC
We've started to see this issue with Xamarin.iOS in both our HockeyApp crash analytics and in day-to-day debugging with the latest stable bits. It doesn't seem to repro with all exceptions.
Comment 11 Kyle White 2016-10-25 16:19:39 UTC
Moving to mono debugger for visibility
Comment 12 Rolf Bjarne Kvinge 2016-10-28 05:27:21 UTC
Workarounds:

#1: pass "--marshal-managed-exceptions=disable" to as an additional mmp/mtouch argument. This will get the old behavior.

#2: add the following code, and the correct stack trace will be printed:

	ObjCRuntime.Runtime.MarshalManagedException += (sender, args) =>
	{
		Console.WriteLine (args.Exception);
	};
Comment 13 Rolf Bjarne Kvinge 2016-10-28 10:57:34 UTC
There are two sides to this issue:

a) The debugger does not stop when the exception is thrown (it's not treated as an unhandled exception when the exception is thrown).
b) The stack trace in the exception object does not contain the original location where the exception was thrown.

A related bug was also filed (bug #45742), I'll leave that bug for part b), and handle part a) in this bug.
Comment 14 Rolf Bjarne Kvinge 2016-10-28 10:58:06 UTC
PR for a): https://github.com/xamarin/xamarin-macios/pull/1055

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