Bug 51162 - Stack Trace and line number missing for Unhandled exceptions in managed code when the debugger IS attached
Summary: Stack Trace and line number missing for Unhandled exceptions in managed code ...
Status: RESOLVED DUPLICATE of bug 45742
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger ()
Version: XI 10.3 (iOS 10.2)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-12-30 16:55 UTC by Tom Harvey
Modified: 2016-12-30 21:40 UTC (History)
2 users (show)

Tags: BZRC8S1_C7SR1S1
Is this bug a regression?: Yes
Last known good build: Xamarin.iOS 9.8.2.22 (Cycle 7 SR 1)


Attachments
What is on the screen after the exception occurs (178.49 KB, image/png)
2016-12-30 16:55 UTC, Tom Harvey
Details
Test case (11.29 KB, application/zip)
2016-12-30 21:34 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 DUPLICATE of bug 45742

Description Tom Harvey 2016-12-30 16:55:40 UTC
Created attachment 19042 [details]
What is on the screen after the exception occurs

Hi, This is driving me crazy! Any help would be appreciated

New to Xamarin and I'm really struggling with a lack of a stack trace and line numbers while running a debug session through the simulator within Xamarin Studio and Visual Studio.

Xamarin.iOS 10.3.1.7 (Xamarin Studio Community)

# Steps to reproduce
1. Create a UITableViewController and implement UITableViewSource with 1 row
2. Create a null reference exception while creating a UITableViewCell like this.


        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier);

            if (cell == null) {
                cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier);
            }

            cell.DetailTextLabel.Text = "Crash here because cell.DetailTextLabel is null. (The cell's UITableViewCellStyle is Default instead of Subtitle)";

            return cell;
        }

# Expected output
Debugger should output a stack trace with the line number of "cell.DetailTextLabel.Text = ..."

# Actual output
Debugger shows a stack trace in Main.cs on this line "UIApplication.Main(args, null, "AppDelegate");"

(Application Output window also doesn't show anything)

Thanks,
Tom
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2016-12-30 21:34:42 UTC
Created attachment 19044 [details]
Test case

## Partial workaround: set the debugger to break on all null reference exceptions

1. Navigate to "Run > New Exception Catchpoint".

2. Under "When an exception is thrown", add "System.NullReferenceException" (without quotation marks).


(In .NET terminology, this tells the debugger to break on all "first chance" null reference exceptions as compared to breaking only on unhandled exceptions.)




## Verification status: verified fixed in the latest Cycle 9 Alpha version (Xamarin.iOS 10.4.0.54)

> GOOD: Xamarin.iOS 10.4.0.54 (master: 4d85810)    + Xcode 8.1 (11544), Build 8B62
> GOOD: Xamarin.iOS 10.4.0.54 (master: 4d85810)    + Xcode 7.3 (10183.3), Build 7D175
> BAD:  Xamarin.iOS 10.3.1.7  (cycle8-xi: 8b53676) + Xcode 8.1 (11544), Build 8B62



## Regression status: regression between Xamarin.iOS 9.8.2 (Cycle 7 SR 1) and 10.0.0 (Cycle 8)

> BAD:  Xamarin.iOS 10.0.0.6 (xcode8: 6c3fee4)     
> GOOD: Xamarin.iOS 9.8.2.22 (cycle7-sr1: f37444a)
> GOOD: Xamarin.iOS 9.6.2.4  (cycle6-xi: d8bedd0)



## Steps to replicate

1. Open the attached test case (tested in Xamarin Studio on Mac).

2. Run the test case on simulator (tested on iPhone 6 iOS 10.1 simulator for Xcode 8.1 and iPhone 6 iOS 9.3 simulator for Xcode 7.3).

3. Click the "Show Table" button.




## BAD results


The debugger breaks on Main.cs, line 12:
> UIApplication.Main(args, null, "AppDelegate");

The full Call Stack at that point is:
> UIKit.UIApplication.UIApplicationMain() in 
> UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) in /Users/builder/data/lanes/3969/8b53676d/source/xamarin-macios/src/UIKit/UIApplication.cs:79
> UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Users/builder/data/lanes/3969/8b53676d/source/xamarin-macios/src/UIKit/UIApplication.cs:63
> SingleViewIphone1.Application.Main(string[] args) in /Users/Shared/Projects/ExceptionInGetCell/SingleViewIphone1/Main.cs:12



## GOOD results (for example when using the workaround)


The debugger breaks on MyTableViewController.cs, line 33:
> cell.DetailTextLabel.Text = "Crash here because cell.DetailTextLabel is null. (The cell's UITableViewCellStyle is Default instead of Subtitle)";

The full Call Stack at that point is:

> SingleViewIphone1.MyTableViewController.GetCell(UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) in /Users/Shared/Projects/ExceptionInGetCell/SingleViewIphone1/MyTableViewController.cs:33
> UIKit.UIApplication.UIApplicationMain() in 
> UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) in /Users/builder/data/lanes/3969/8b53676d/source/xamarin-macios/src/UIKit/UIApplication.cs:79
> UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Users/builder/data/lanes/3969/8b53676d/source/xamarin-macios/src/UIKit/UIApplication.cs:63
> SingleViewIphone1.Application.Main(string[] args) in /Users/Shared/Projects/ExceptionInGetCell/SingleViewIphone1/Main.cs:12



## Additional testing environment info (brief)

Mono 4.6.2 (mono-4.6.0-branch/ac9e222)
Xamarin Studio 6.1.3 (build 9) (aa9576a)

Xcode 7.3 (10183.3), Build 7D175
Mac OS 10.11.6
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2016-12-30 21:38:00 UTC
Based on the verification status and the correspondence of the symptoms, I am comfortable marking this as a duplicate of Bug 45742.

*** This bug has been marked as a duplicate of bug 45742 ***