Bug 25937 - Intermittent Null Reference Exceptions using the Unified API
Summary: Intermittent Null Reference Exceptions using the Unified API
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.11.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: 2.4.0 (C6)
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-01-12 13:53 UTC by John Miller [MSFT]
Modified: 2015-03-18 18:18 UTC (History)
5 users (show)

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


Attachments
Stack Traces and Sample Code (151.88 KB, text/plain)
2015-01-12 13:53 UTC, John Miller [MSFT]
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 John Miller [MSFT] 2015-01-12 13:53:05 UTC
Created attachment 9324 [details]
Stack Traces and Sample Code

**Overview:**

   Since updating to the Unified API, intermittent NRE errors are happening. The same code is shared with iOS and is not having this issue. Please see the attached doc for examples and stack traces. 

**Steps to Reproduce:**

   A sample is not possible at this time as it is intermittent. 

**Actual Results:**

   Varying stack traces, but they all seem to be NullReferenceExceptions. 

**Expected Results:**

   No exceptions. 

**Build Date & Platform:**

   XMac 1.11.03
   Mono 3.12

**Additional Information:**

   The problem is intermittent and hard to reproduce. The same shared code on iOS does not seem to reproduce the intermittent issues. These issues only surfaced after updating to the Unified API. The Classic API did not produce these exceptions in this code.
Comment 1 Chris Hamons 2015-02-17 08:59:29 UTC
So, the first error could be related to the issue posted here:

https://github.com/JamesNK/Newtonsoft.Json/issues/451

"excluding System.Core and System.Runtime.Serialization from linking fixes the issue".

Have you enabled linking in the project settings? If so, try adding --linkskip=System.Core --linkskip= System.Runtime.Serialization or disable linking to see if that "fixes" the issue.

Is your iOS application also Unified? If so, you need to have both of these check boxes enabled:

"Use the SGen generational garbage collector"
"Use the reference counting extension"

to have the same behavior as iOS. Try checking both, and see if the other issue(s) go away.
Comment 2 Bart King 2015-02-18 12:57:05 UTC
Cheers Chris, here's my results:

- Adding those linkskip options does indeed make Json.Net work fine. 
- My iOS version did have reference counting disabled, so I also disabled it on Mac and these random crashes seem to have disappeared.

Now that the app runs, there seems to be a few problems in other areas, but I'll raise those on the forum since they seem to be API differences and not related to this bug.
Comment 3 Chris Hamons 2015-02-18 14:22:25 UTC
Good to know. We have some long term work needed to make the linkskip lines unnecessary. 

You might want to track down the reference counting issue and file a specific bug, as removing that option in a future version for Mac on Unified.
Comment 5 Timothy Risi 2015-03-18 18:18:00 UTC
Closing since this should be fixed on master (b5f51d542379ef51e64b0267952d945838571097) that the linker xml file has been ported from iOS but we don't have a repro for it to validate.