Bug 5320 - NullReferenceException in Array.Copy
Summary: NullReferenceException in Array.Copy
Status: RESOLVED DUPLICATE of bug 3676
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-25 05:23 UTC by Ruben Vermeersch
Modified: 2012-07-16 18:29 UTC (History)
2 users (show)

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


Attachments
Readable trace (4.61 KB, text/plain)
2012-05-25 05:25 UTC, Ruben Vermeersch
Details
New trace (2.78 KB, text/plain)
2012-05-25 08:58 UTC, Ruben Vermeersch
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 3676

Description Ruben Vermeersch 2012-05-25 05:23:52 UTC
This is probably a duplicate of bug 3676, but I'm filing it again as we consistently see it happening (which frightens me quite a bit):

System.NullReferenceException: Object reference not set to an instance of an object
  at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex, System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x00000] in <filename unknown>:0 
  at System.Collections.ArrayList.CopyTo (Int32 index, System.Array array, Int32 arrayIndex, Int32 count) [0x00000] in <filename unknown>:0 
  at System.Collections.ArrayList.CopyTo (System.Array array, Int32 arrayIndex) [0x00000] in <filename unknown>:0 
  at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 
  at System.MonoType.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttributes[DataContractAttribute] (ICustomAttributeProvider attributeProvider, Boolean inherit) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttribute[DataContractAttribute] (ICustomAttributeProvider attributeProvider, Boolean inherit) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute[DataContractAttribute] (System.Type type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute[DataContractAttribute] (ICustomAttributeProvider attributeProvider) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Reflection.ICustomAttributeProvider,System.Runtime.Serialization.DataContractAttribute].AddValue (ICustomAttributeProvider key) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Reflection.ICustomAttributeProvider,System.Runtime.Serialization.DataContractAttribute].Get (ICustomAttributeProvider key) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.CachedAttributeGetter`1[System.Runtime.Serialization.DataContractAttribute].GetAttribute (ICustomAttributeProvider type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonTypeReflector.GetDataContractAttribute (System.Type type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Type,Newtonsoft.Json.Serialization.JsonContract].AddValue (System.Type key) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Type,Newtonsoft.Json.Serialization.JsonContract].Get (System.Type key) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe (System.Type type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType (Newtonsoft.Json.JsonReader reader, System.Type t, Newtonsoft.Json.JsonConverter propertyConverter) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject[StartLocationsResponse] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject[StartLocationsResponse] (System.String value) [0x00000] in <filename unknown>:0 
  at WestVlinderen.DataManager.<SyncStartLocations>m__0 (WestVlinderen.BackendRequest sender) [0x00000] in <filename unknown>:0 
  at WestVlinderen.BackendRequest.SignalSuccess () [0x00000] in <filename unknown>:0 
  at WestVlinderen.BackendRequest+<DoRequest>c__AnonStorey2.<>m__8 (IAsyncResult ar) [0x00000] in <filename unknown>:0 
  at System.Net.WebAsyncResult.CB (System.Object unused) [0x00000] in <filename unknown>:0 

The good thing is that this only happens right after startup of the app.

Version info:

MonoDevelop 3.0.2
Installation UUID: 46adcb2c-0fef-4128-a852-9a6bc9a39109
Runtime:
	Mono 2.10.9 (tarball Mon May  7 20:25:51 EDT 2012)
	GTK 2.24.10
	GTK# (2.12.0.0)
	Package version: 210090011
Apple Developer Tools:
	 Xcode 4.3.2 (1177)
	 Build 4E2002
Monotouch: 5.2.12
Mono for Android: 4.2.2.134493563
Android SDK: /Users/ruben/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
	Version: 1.6	ApiLevel: 4
	Version: 2.1	ApiLevel: 7
	Version: 2.2	ApiLevel: 8
	Version: 2.3	ApiLevel: 10
	Version: 3.1	ApiLevel: 12
	Version: 4.0	ApiLevel: 14
	Version: 4.0.3	ApiLevel: 15
Java SDK: /usr/bin

Build information:
	Release ID: 30002000
	Git revision: 046db1bb0d9d438aa4d3468d66c6f963bc44c51a-dirty
	Build date: 2012-05-23 21:39:54+0000
	Xamarin addins: d99a1741642a336943d5607bdc1a09efa2ac3b86
Operating System:
	Mac OS X 10.7.4
	Darwin tsukuba.local 11.4.0 Darwin Kernel Version 11.4.0
	    Mon Apr  9 19:32:15 PDT 2012
	    root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
Comment 1 Ruben Vermeersch 2012-05-25 05:25:01 UTC
Created attachment 1952 [details]
Readable trace
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-05-25 06:54:50 UTC
Can you try the 5.3.3 alpha? Bug #3676 should be fixed there, so if this doesn't happen anymore in the alpha, it means it's a dup.
Comment 3 Ruben Vermeersch 2012-05-25 08:58:24 UTC
Created attachment 1953 [details]
New trace

Oh my bad. I assumed it already landed in MonoTouch, that's why I filed it.

When I run from alpha, I now get the attached trace, which is a different race condition (I assume). So yes, this will probably be solved
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-05-29 07:47:55 UTC
Ruben, do you get that NullReferenceException when running without the debugger? Is it 100% reproducible or does it just happen once in a while?
Comment 5 Ruben Vermeersch 2012-06-04 03:26:58 UTC
As far as I can tell, it happens from time to time (and not all that often). These are crash reports we get from on-device (production) usage.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2012-06-04 17:29:16 UTC
At first sight this looks like a race condition in Newtonsoft.Json (I don't know the exact version you're using, so I can't say for sure), and in any case it has nothing to do with the original issue reported, so I'm closing this bug for now.

For the last NullReferenceException, if you believe it is a bug in MonoTouch, feel free to open a new bug about it (have in mind though that we'll likely need to reproduce it somehow ourselves in order to figure out what's going on).

*** This bug has been marked as a duplicate of bug 3637 ***
Comment 7 Rolf Bjarne Kvinge [MSFT] 2012-07-16 18:29:09 UTC
Duplicate of bug #3676, not #3637.

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