We are seeing the following stack trace in a Xamarin.iOS app in Raygun.
NullReferenceException: Object reference not set to an instance of an object
System.Net.ServicePoint.CheckAvailableForRecycling(System.DateTime& outIdleSince) in <filename unknown>:0
System.Net.ServicePoint.IdleTimerCallback(System.Object obj) in <filename unknown>:0
System.Threading.Timer+Scheduler.TimerCB(System.Object o) in <filename unknown>:0
We are using Xamarin.iOS 188.8.131.52 and have seen the error reported on iOS 8 and 9.
I believe the error has to do with this commit: https://github.com/mono/mono/commit/a769e74c5320f2cfa85efe80f2e1c1d8470c271b
Specifically, https://github.com/mono/mono/blob/a769e74c5320f2cfa85efe80f2e1c1d8470c271b/mcs/class/System/System.Net/ServicePoint.cs#L317 might need a check for groups != null.
1. Thread 1 calls CheckAvailableForRecycling
2. Thread 2 calls CheckAvailableForRecycling
3. Thread 1 locks (this) and builds groupList
4. Thread 2 locks (this) and builds groupList, while Thread 1 is iterating groupList (lines 304-310)
5. Thread 1 locks (this) on line 312, while Thread 2 is iterating groupList.
6. While holding lock, Thread 1 sets groups to null.
7. Thread 1 exits lock
8. Thread 2 locks (this) on line 312 and groups is null. => NRE
Fixed in mono master and Mono 4.2
*** Bug 32689 has been marked as a duplicate of this bug. ***
*** Bug 34745 has been marked as a duplicate of this bug. ***
*** Bug 35226 has been marked as a duplicate of this bug. ***
Only Xamarin.iOS 9.2 or newer versions have the fix included
Not fixed: Xcode 7.2, mtouch 184.108.40.206 (cycle6-xi: eb4c1ef), /Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5
Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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.
Create a new report for Bug 32685 on Developer
Community or GitHub if you have new information to add and do not yet see a matching
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
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.