Bug 41528 - NSIndexPath from FromIndex crash when expanded in debugger due to native assertion
Summary: NSIndexPath from FromIndex crash when expanded in debugger due to native asse...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 2.9.0
Hardware: Macintosh Mac OS
: High normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2016-06-06 12:48 UTC by Colby Williams
Modified: 2016-07-20 19:45 UTC (History)
3 users (show)

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


Attachments
Repro project (348.30 KB, application/zip)
2016-06-06 12:51 UTC, Colby Williams
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 Colby Williams 2016-06-06 12:48:10 UTC
To reproduce, add the following lines to a Xamarin.Mac app:

	var ip = NSIndexPath.FromIndex (1);
	System.Console.WriteLine (ip.Item);

Also, setting a breakpoint on Console.WriteLine, hovering over the ip var and expanding to view properties will crash the app.

crash log output: https://gist.github.com/colbylwilliams/ba620fa9e51224dee5893dd0dfe23564

version info: https://gist.github.com/colbylwilliams/a3d078c3f99eb46c4ea780fde8638bc8
Comment 1 Colby Williams 2016-06-06 12:51:56 UTC
Created attachment 16199 [details]
Repro project

Adding a repro project for simplicity.  The relevant code (two lines from original comment) is in AppDelegate.cs
Comment 2 Chris Hamons 2016-06-06 14:57:26 UTC
The same code in objective-c:

    NSIndexPath * i = [[NSIndexPath alloc] initWithIndex:1];
    NSLog (@"%ld", i.item);

gives the same exception:

2016-06-06 09:47:39.724 ButtonTest[39242:16082641] Invalid index path for use with NSCollectionView.  Index paths passed to collection view must contain exactly two indices specifying the section and row.  Please use the category on NSIndexPath in NSCollectionView.h if possible.

however, it is not fatal there. 

Swapping to:

var ip = NSIndexPath.FromItemSection (0, 0);

and it "works".

I'm going to keep the bug around, since we should try to either catch this assertion or at least make the properties not auto expand in the debugger (to prevent crashes).
Comment 3 Chris Hamons 2016-06-09 15:49:58 UTC
So it turns out that objective-c code throws a nasty gram in mac in Xcode but not iOS. Apple has different behavior. :(

Rolf is introducing "--marshal-objectivec-exceptions=throwmanaged" which will be the default in 64-bit debug which promotes this to a managed exception, which prevents the watch/local window from killing us by expanding an index path.

I don't think we really can't remove the item property from the watch window / index. It is a rather common one.
Comment 7 Chris Hamons 2016-07-20 19:45:06 UTC
So for reasons of backwards compatibility we can't make --marshal-objectivec-exceptions=throwmanaged default, but @rajneesh if you add --marshal-objectivec-exceptions=throwmanaged as an additional mmp argument with a modern build you should see that it is fixed.