Unhandled Exception Crash

Oct 1, 2010 at 11:02 PM

I'm getting the below stack trace.  The Exception is unhandled to the point that it blue screens my server sometimes.

Application: JSON2XML.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Runtime.InteropServices.SEHException Stack: at System.Security.Cryptography.RIPEMD160Managed..ctor() at System.Globalization.CompareInfo.InternalFindNLSStringEx(IntPtr, System.String, Int32, System.String, Int32, Int32, System.String, Int32) at System.Globalization.CompareInfo.LastIndexOf(System.String, System.String, Int32, Int32, System.Globalization.CompareOptions) at System.String.LastIndexOf(System.String, Int32, Int32, System.StringComparison) at System.RuntimeType.SplitName(System.String, System.String ByRef, System.String ByRef) at System.RuntimeType.GetInterface(System.String, Boolean) at System.Type.GetInterface(System.String) at System.Security.PermissionToken.FindToken(System.Type) at System.Security.PermissionSet.RemovePermissionImpl(System.Type) at System.Security.PermissionSet.CopyWithNoIdentityPermissions() at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32, System.Security.PermissionSet, System.Threading.CompressedStack) at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32, System.Security.PermissionSet) at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(System.Security.PermissionType, System.Security.PermissionSet) at System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(System.Type, System.Threading.StackCrawlMark ByRef, Boolean) at System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], System.Type, Boolean) at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod(System.String, System.Type, System.Type[], System.Type) at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Type) at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator(System.Type) at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(Newtonsoft.Json.Serialization.JsonContract) at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateArrayContract(System.Type) at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(System.Type) at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(System.Type) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Newtonsoft.Json.JsonReader, System.Type) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(Newtonsoft.Json.JsonReader, System.Type) at Newtonsoft.Json.JsonConvert.DeserializeObject(System.String, System.Type, Newtonsoft.Json.JsonSerializerSettings) at Newtonsoft.Json.JsonConvert.DeserializeObject(System.String, System.Type, Newtonsoft.Json.JsonConverter[]) at Newtonsoft.Json.JsonConvert.DeserializeXmlNode(System.String, System.String) at JSON2XML.Program.Main(System.String[])

Has anyone seen this behavior or know how to work around it?

Oct 2, 2010 at 9:52 PM

To add some more information on this: I am deploying my app on a Windows 2008 R2 server.  The app is called for each file in a directory system so is called many hundreds of times.  The odd thing is it works fine, then all of a sudden it will start failing and within 5-20 failures will fail so hard it will blue screen the server.  After the server reboots, it has no problem processing the files it failed on earlier.  So it does not appear to have anythign to do with the files themselves.  Iguessing at some point it corrupts the environment and then cannot run anymore, with further attempts to run risk blue screening the server.

Coordinator
Oct 2, 2010 at 11:23 PM

Fantastic. I've never seen anything like this before. The error is coming from a call deep inside .NET... The only possible idea I have that it is caused by the System.__Canon type you are attempting to serialize.

Application: JSON2XML.exe Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.SEHException Stack:
at System.Security.Cryptography.RIPEMD160Managed..ctor()
at System.Globalization.CompareInfo.InternalFindNLSStringEx(IntPtr, System.String, Int32, System.String, Int32, Int32, System.String, Int32)
at System.Globalization.CompareInfo.LastIndexOf(System.String, System.String, Int32, Int32, System.Globalization.CompareOptions)
at System.String.LastIndexOf(System.String, Int32, Int32, System.StringComparison) at System.RuntimeType.SplitName(System.String, System.String ByRef, System.String ByRef)
at System.RuntimeType.GetInterface(System.String, Boolean) at System.Type.GetInterface(System.String) at System.Security.PermissionToken.FindToken(System.Type)
at System.Security.PermissionSet.RemovePermissionImpl(System.Type) at System.Security.PermissionSet.CopyWithNoIdentityPermissions()
at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32, System.Security.PermissionSet, System.Threading.CompressedStack)
at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32, System.Security.PermissionSet) at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(System.Security.PermissionType, System.Security.PermissionSet)
at System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(System.Type, System.Threading.StackCrawlMark ByRef, Boolean)
at System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], System.Type, Boolean) at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod(System.String, System.Type, System.Type[], System.Type)
at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Type)
at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator(System.Type)
at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(Newtonsoft.Json.Serialization.JsonContract)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateArrayContract(System.Type)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(System.Type)
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(System.Type)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Newtonsoft.Json.JsonReader, System.Type)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(Newtonsoft.Json.JsonReader, System.Type)
at Newtonsoft.Json.JsonConvert.DeserializeObject(System.String, System.Type, Newtonsoft.Json.JsonSerializerSettings)
at Newtonsoft.Json.JsonConvert.DeserializeObject(System.String, System.Type, Newtonsoft.Json.JsonConverter[])
at Newtonsoft.Json.JsonConvert.DeserializeXmlNode(System.String, System.String) at JSON2XML.Program.Main(System.String[])

Coordinator
Oct 2, 2010 at 11:27 PM

That might not be the error. I'm really not sure.

Oct 2, 2010 at 11:40 PM

Thanks for the reply!  The code I am using is quite simple and not sure what System._Canon is.  I am actually only calling two methods from the lib.  It may be coincidental but I notice the "Software Protection" service appears to have some activity just before and after the crashes.  It stops and restarts itself.  Anyway, I am not the most proficient at this point for tracing down this kind of error but I am happy to try.  If you have any pointers let me know.  Will let you know what I find.

 

My code excerpt:

 

XmlDocument doc = new XmlDocument ();

 

doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json, "json" );

 

xml = doc.InnerXml;

 

XmlFile.Write(xml);

Oct 4, 2010 at 12:37 AM

I've figured out a bit more of this.  As I previously mentioned, I'm using this JSON.net lib in a console app that is called by an SSIS package that will convert JSON files to XML files one by one and load them into SQL server.  What I think was occuring is there would be an error related to a JSON file, a bad value or data type that would prevent the deserialization to XML.  My json to xml converter app would crash as a result, but somehow it would remain in memory.  I verified this when I saw several of my app processes in task manager.  So subsquent calls to my app would have unhandled exceptions, I believe because the app is being called while another copy of itself is still in memory.  I put a "taskkill" step in my SSIS package to kill my app if it is resident in memory before calling it again and that seems to correct the blue screens and repeat failures so I am just left with a bunch of files that won't convert that I need to research further.