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 184.108.40.206 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 220.127.116.11 (cycle6-xi: eb4c1ef), /Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5