raven-csharp icon indicating copy to clipboard operation
raven-csharp copied to clipboard

DllNotFoundExceptions and SecurityException when using with Mono

Open knocte opened this issue 7 years ago • 32 comments

When testing my app in Ubuntu 18.04, I've seen these stacktraces when SharpRaven apparently tried to send reports to Sentry:

[ERROR] System.DllNotFoundException: api-ms-win-core-sysinfo-l1-1-0.dll
  at (wrapper managed-to-native) Interop+mincore:GetSystemInfo (Interop/mincore/SYSTEM_INFO&)
  at System.Runtime.InteropServices.RuntimeInformation.get_ProcessArchitecture () [0x0001c] in <dd91439f3167478ebd2cbf9c036a1395>:0 
  at SharpRaven.Data.Context.Device.GetArchitecture () [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Data.Context.Device.Create () [0x0001b] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
[ERROR] System.DllNotFoundException: ntdll.dll
  at (wrapper managed-to-native) Interop+NtDll:RtlGetVersion (Interop/NtDll/RTL_OSVERSIONINFOEX&)
  at Interop+NtDll.RtlGetVersion () [0x0001a] in <dd91439f3167478ebd2cbf9c036a1395>:0 
  at System.Runtime.InteropServices.RuntimeInformation.get_OSDescription () [0x00007] in <dd91439f3167478ebd2cbf9c036a1395>:0 
  at SharpRaven.Data.Context.OperatingSystem.Create () [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
[ERROR] System.Security.SecurityException: No access to the given key ---> System.UnauthorizedAccessException: Access to the path "/etc/mono/registry" is denied.
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00070] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.DirectoryInfo.Create () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0003f] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir, System.Boolean is_volatile) [0x0004a] in <8f2c484307284b51944a1a13a14c0266>:0 
   --- End of inner exception stack trace ---
  at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir, System.Boolean is_volatile) [0x00062] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.KeyHandler.Lookup (Microsoft.Win32.RegistryKey rkey, System.Boolean createNonExisting) [0x000ce] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.UnixRegistryApi.OpenSubKey (Microsoft.Win32.RegistryKey rkey, System.String keyname, System.Boolean writable) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.RegistryKey.OpenSubKey (System.String name, System.Boolean writable) [0x0001e] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.RegistryKey.OpenSubKey (System.String name) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) Microsoft.Win32.RegistryKey:OpenSubKey (string)
  at SharpRaven.Utilities.RuntimeInfoHelper.Get45PlusLatestInstallationFromRegistry () [0x0000f] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Utilities.RuntimeInfoHelper.GetRuntime () [0x00019] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Data.Context.Runtime.Create () [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 

knocte avatar Nov 14 '18 03:11 knocte

It's trying to get .NET Framework installation through Get45PlusLatestInstallationFromRegistry while running on Mono. This code path only makes sense when running on Windows though.

The code does have a guard:

https://github.com/getsentry/raven-csharp/blob/952adead4551042b51fa624982a8804ddb8752a6/src/app/SharpRaven/Utilities/RuntimeInfoHelper.cs#L40-L43

Could you please describe your app a bit? what version of the framework you are using?

bruno-garcia avatar Nov 14 '18 10:11 bruno-garcia

I guess I haven't seen this again.

knocte avatar Nov 15 '19 13:11 knocte

That's good to know. do you plan to move to NuGet package Sentry? What are the reasons not to? Tks

bruno-garcia avatar Nov 15 '19 13:11 bruno-garcia

What are the reasons not to?

I already explained in some other github issue I think: doesn't have Xamarin.iOS support.

knocte avatar Nov 15 '19 15:11 knocte

https://github.com/getsentry/sentry-dotnet/issues/122

knocte avatar Nov 15 '19 15:11 knocte

There was an update to that thread because of other customers reporting they use it with Xamarin iOS and Android but if things are working fine for you as is, makes sense to stay.

I hope we get to focus on Xamarin for a bit to make sure the experience is good. Likely releasing Sentry.Xamarin

bruno-garcia avatar Nov 15 '19 15:11 bruno-garcia

makes sense to stay.

Exactly, especially taking in account that sentry-dotnet seems to only be better than raven-csharp in one aspect: storing exceptions when app is offline, to send them later. IMO this is a feature that I would rarely benefit from. Make sentry-dotnet more compelling, and I might evaluate it myself on Xamarin platforms.

knocte avatar Nov 15 '19 15:11 knocte

I believe you think there's no compelling feature then because offline mode is not there yet. We would do that as part of the Xamarin support.

IMHO (a bias one) there are many reasons to change. Main ones I can think of are:

  • Background event submission means you don't delay user interaction while events are sent to Sentry. In the new SDK events are sent in the background for that reason. If you need to wait for the event to flush you can call await SentrySdk.FlushAsync().
  • Request body is compressed which makes it faster to send and uses less user data.
  • Debug mode which helps you see what the SDK is doing
  • Uses HttpClient instead of HttpWebRequest
  • It has a Scope you can use to add data that later gets added to events going out on the same scope
  • Strong naming (if you need that)
  • Sourcelink so u can debug though the SDK
  • Packages are decoupled so we can build stuff on top (like ASPNET Core is its own package so you don't need Web related stuff happening on Xamarin app)
  • Event processors you can add to the scope or to SentryOptions.
  • Doesn't support 429 so you might be flooding sentry and using customer data plan

I understand many of those do not apply to you. I'm still trying to push to get proper Xamarin support (send device data automatically etc) in which case I'll be updating that other issue and hopefully have a compelling reason to have you move over.

bruno-garcia avatar Nov 15 '19 15:11 bruno-garcia

Hey I've seen this issue again, it should be reopened. Can we get a hotfix? If running on Linux it should not call Interop+NtDll.RtlGetVersion at all.

knocte avatar Dec 17 '19 10:12 knocte

New stacktrace:

[ERROR] System.DllNotFoundException: api-ms-win-core-sysinfo-l1-1-0.dll
  at (wrapper managed-to-native) Interop+mincore:GetSystemInfo (Interop/mincore/SYSTEM_INFO&)
  at System.Runtime.InteropServices.RuntimeInformation.get_ProcessArchitecture () [0x0001c] in <dd91439f3167478ebd2cbf9c036a1395>:0 
  at SharpRaven.Data.Context.Device.GetArchitecture () [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Data.Context.Device.Create () [0x0001b] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
[ERROR] System.DllNotFoundException: ntdll.dll
  at (wrapper managed-to-native) Interop+NtDll:RtlGetVersion (Interop/NtDll/RTL_OSVERSIONINFOEX&)
  at Interop+NtDll.RtlGetVersion () [0x0001a] in <dd91439f3167478ebd2cbf9c036a1395>:0 
  at System.Runtime.InteropServices.RuntimeInformation.get_OSDescription () [0x00007] in <dd91439f3167478ebd2cbf9c036a1395>:0 
  at SharpRaven.Data.Context.OperatingSystem.Create () [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
[ERROR] System.Security.SecurityException: No access to the given key ---> System.UnauthorizedAccessException: Access to the path "/snap/gwallet/x1/usr/etc" is denied.
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00070] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.DirectoryInfo.Create () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0003f] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.DirectoryInfo.Create () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0003f] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.DirectoryInfo.Create () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0003f] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir, System.Boolean is_volatile) [0x0004a] in <8f2c484307284b51944a1a13a14c0266>:0 
   --- End of inner exception stack trace ---
  at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir, System.Boolean is_volatile) [0x00062] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.KeyHandler..ctor (Microsoft.Win32.RegistryKey rkey, System.String basedir) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.KeyHandler.Lookup (Microsoft.Win32.RegistryKey rkey, System.Boolean createNonExisting) [0x000ce] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.UnixRegistryApi.OpenSubKey (Microsoft.Win32.RegistryKey rkey, System.String keyname, System.Boolean writable) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.RegistryKey.OpenSubKey (System.String name, System.Boolean writable) [0x0001e] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.Win32.RegistryKey.OpenSubKey (System.String name) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at (wrapper remoting-invoke-with-check) Microsoft.Win32.RegistryKey:OpenSubKey (string)
  at SharpRaven.Utilities.RuntimeInfoHelper.Get45PlusLatestInstallationFromRegistry () [0x0000f] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Utilities.RuntimeInfoHelper.GetRuntime () [0x00019] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Data.Context.Runtime.Create () [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
[ERROR] System.TypeInitializationException: The type initializer for 'System.Net.WebRequest' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <startup> (/snap/gwallet/x1/lib/gwallet/GWallet.Frontend.Console.exe.config line 3)
  at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00007] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed, System.Boolean root) [0x00170] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed) [0x00007] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x000ec] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.Load () [0x00052] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.Init (System.Configuration.Internal.IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00065] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x0005c] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000e] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (System.Configuration.ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00107] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00011] in <d6de850e07274db588ca7c247bfa5ec6>:0 
   --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00030] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00005] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Net.WebRequest..cctor () [0x00014] in <bd46d4d4f7964dfa9beea098499ab597>:0 
   --- End of inner exception stack trace ---
  at SharpRaven.Data.Requester.CreateWebRequest (System.Uri uri) [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Data.Requester..ctor (SharpRaven.Data.JsonPacket packet, SharpRaven.RavenClient ravenClient) [0x0004f] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.RavenClient.Send (SharpRaven.Data.JsonPacket packet) [0x00002] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
System.TypeInitializationException: The type initializer for 'System.Net.ServicePointManager' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <startup> (/snap/gwallet/x1/lib/gwallet/GWallet.Frontend.Console.exe.config line 3)
  at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00007] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed, System.Boolean root) [0x00170] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed) [0x00007] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x000ec] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.Load () [0x00052] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.Init (System.Configuration.Internal.IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00065] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x0005c] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000e] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (System.Configuration.ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00107] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00011] in <d6de850e07274db588ca7c247bfa5ec6>:0 
   --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00030] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00005] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Net.ServicePointManager..cctor () [0x00040] in <bd46d4d4f7964dfa9beea098499ab597>:0 
   --- End of inner exception stack trace ---
  at System.Net.Http.HttpClientHandler.Dispose (System.Boolean disposing) [0x0001d] in <41c316444c8a4380b9344ba09eeb18de>:0 
  at System.Net.Http.HttpMessageHandler.Dispose () [0x00000] in <41c316444c8a4380b9344ba09eeb18de>:0 
  at System.Net.Http.HttpMessageInvoker.Dispose (System.Boolean disposing) [0x0001c] in <41c316444c8a4380b9344ba09eeb18de>:0 
  at System.Net.Http.HttpClient.Dispose (System.Boolean disposing) [0x00023] in <41c316444c8a4380b9344ba09eeb18de>:0 
  at System.Net.Http.HttpMessageInvoker.Dispose () [0x00000] in <41c316444c8a4380b9344ba09eeb18de>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+IntrinsicFunctions.Dispose[T] (T resource) [0x0000a] in <039b17603f7a807e0eeaa652dc64c784>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+disposeFunction@595-1[b,T].Invoke (b _arg1) [0x00014] in <039b17603f7a807e0eeaa652dc64c784>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenContinue[a,b] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, a arg, Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt) [0x00005] in <039b17603f7a807e0eeaa652dc64c784>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+econt@492[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo exn) [0x0002f] in <039b17603f7a807e0eeaa652dc64c784>:0 
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@943-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00080] in <039b17603f7a807e0eeaa652dc64c784>:0 
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <039b17603f7a807e0eeaa652dc64c784>:0 
[ERROR] System.TypeInitializationException: The type initializer for 'System.Net.WebRequest' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <startup> (/snap/gwallet/x1/lib/gwallet/GWallet.Frontend.Console.exe.config line 3)
  at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00007] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed, System.Boolean root) [0x00170] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed) [0x00007] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x000ec] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.Load () [0x00052] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration.Init (System.Configuration.Internal.IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00065] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x0005c] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000e] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (System.Configuration.ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00107] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00011] in <d6de850e07274db588ca7c247bfa5ec6>:0 
   --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00030] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00005] in <d6de850e07274db588ca7c247bfa5ec6>:0 
  at System.Net.WebRequest..cctor () [0x00014] in <bd46d4d4f7964dfa9beea098499ab597>:0 
   --- End of inner exception stack trace ---
  at SharpRaven.Data.Requester.CreateWebRequest (System.Uri uri) [0x00000] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Data.Requester..ctor (SharpRaven.Data.JsonPacket packet, SharpRaven.RavenClient ravenClient) [0x0004f] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.RavenClient.Send (SharpRaven.Data.JsonPacket packet) [0x00002] in <9d0d9023551f4804a7104ebbc1f9bfae>:0

knocte avatar Dec 17 '19 10:12 knocte

I think this is the more narrowed culprit:

  at (wrapper remoting-invoke-with-check) Microsoft.Win32.RegistryKey:OpenSubKey (string)
  at SharpRaven.Utilities.RuntimeInfoHelper.Get45PlusLatestInstallationFromRegistry () [0x0000f] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Utilities.RuntimeInfoHelper.GetRuntime () [0x00019] in <9d0d9023551f4804a7104ebbc1f9bfae>:0 
  at SharpRaven.Data.Context.Runtime.Create ()

knocte avatar Dec 17 '19 10:12 knocte

Hi @knocte Could you please provide some context like the version of the Mono runtime, the Linux distro? That's an F# app running ASP.NET on Mono or a desktop app on Linux?

The first stack trace seems to hit get_ProcessArchitecture which happens in System.Runtime.InteropServices.RuntimeInformation. What version of this assembly do you have loaded? Seems like it picked the assembly for Windows.

It happens here:

https://github.com/getsentry/raven-csharp/blob/952adead4551042b51fa624982a8804ddb8752a6/src/app/SharpRaven/Utilities/RuntimeInfoHelper.cs#L39-L44

Finally, it seems this just gets logged out to console but no crash happens, is that correct?

https://github.com/getsentry/raven-csharp/blob/952adead4551042b51fa624982a8804ddb8752a6/src/app/SharpRaven/Data/Context/Runtime.cs#L91-L101

bruno-garcia avatar Dec 17 '19 17:12 bruno-garcia

Could you please provide some context like the version of the Mono runtime, the Linux distro?

Ubuntu 18.04 LTS

That's an F# app running ASP.NET on Mono or a desktop app on Linux?

F# desktop app on Linux running Mono 6.6.0.161

What version of this assembly do you have loaded? Seems like it picked the assembly for Windows.

How can I know that?

gets logged out to console but no crash happens, is that correct?

Yes true, but the error is not sent to Sentry.

knocte avatar Dec 17 '19 18:12 knocte

@knocte Have you tried the Sentry SDK? I know you're aware of it and have chosen not to migrate for Xamarin but what about your desktop app?

bruno-garcia avatar Dec 17 '19 20:12 bruno-garcia

In other words, what's blocking you to move over to the new SDK where it's more active development and bugfixes etc?

bruno-garcia avatar Dec 17 '19 20:12 bruno-garcia

I'd like to move/test that for separate reasons than this bug which should be simple to fix.

knocte avatar Dec 18 '19 02:12 knocte

@bruno-garcia can you reopen this please?

knocte avatar Feb 17 '20 09:02 knocte

Hi @knocte I'm happy to merge a PR and make a release for this. Or of you provide a repro I can try to investigate. But please note we're not maintaining this SDK, last release was almost 2 years ago.

Are you using Xamarin.iOS? Also Xamarin.Android? I'm interested in investigating support based on the Sentry package. Would be interested in collaborating on this?

bruno-garcia avatar Feb 17 '20 16:02 bruno-garcia

@knocte, I cannot reproduce the test failures with either Runtime, Device or OperatingSystem on my local build of the develop branch (updated with Cake 0.37, see PR #283)

For OperatingSystem, the error in the trace above is in SharpRaven.Data.Context.OperatingSystem.Create ().

I am testing that function using

nunit-console build/Debug/net471/SharpRaven.UnitTests.dll -fixture:SharpRaven.UnitTests.Data.Context.OperatingSystemTests

If you look at the OperatingSystemTests.cs, it does call OperatingSystem.Create().

I also tried with the net35 version, it still works. (tests pass)

The same applies to Device, which I have tested using

nunit-console build/Debug/net35/SharpRaven.UnitTests.dll -fixture:SharpRaven.UnitTests.Data.Context.DeviceTests.

The same also applies to Runtime, which I have tested using

nunit-console build/Debug/net35/SharpRaven.UnitTests.dll -fixture:SharpRaven.UnitTests.Data.Context.RuntimeTests

I also tried swapping out my built SharpRaven.dll with the one in Nuget at version 2.4.0. The tests still passed.

Can you reproduce the failure by running the test? Maybe it fails if you build on Windows and use the built dll on Mono, or something?

ysangkok avatar Apr 07 '20 20:04 ysangkok

@ysangkok did you try to reproduce this problem exactly how it's explained in the first comment? That is, throw an exception somewhere in the app (after the SharpRaven event subscription happens), push your change to some branch, let gitlab generate an artifact, grab those artifacts and try to run the app in Ubuntu 18.04.

knocte avatar Apr 08 '20 04:04 knocte

of the develop branch

Last git tag in this repository is 2.4, which matches with the nuget package last version: 2.4.0. The last commit in this tag is in May2018 so there's a chance that the develop branch maybe has a fix for this that has not been released? try building this tag to confirm...

on my local build

Actually, first thing I would try is reproducing the problem from the nuget package, not with a local build. After you have reproduced it with the nuget package, try a local build to fix it, however, if with a local build you cannot reproduce it, there's a high chance that the culprit is because, I'm guessing, the nuget package gets built & uploaded from a Windows box. So maybe there's some behaviour in this lib that is determined by the OS/Platform that is being built from, instead of run from?

knocte avatar Apr 08 '20 06:04 knocte

As mentioned, i have also tried with the released 2.4.0 dll.

Regarding doing subscriptions first, i don't understand how that could make a difference since we are talking about exceptions in static initializes that depend on build flags. So the thing to ensure is that the right build flags are getting set. I will try building on Windows and testing that build on mono.

ysangkok avatar Apr 08 '20 14:04 ysangkok

Regarding doing subscriptions first

With this, I mean, very specifically, this method being called first: https://github.com/nblockchain/geewallet/blob/master/src/GWallet.Backend/Infrastructure.fs#L85 and then after that, throw an exception

, i don't understand how that could make a difference since we are talking about exceptions in static initializes that depend on build flags

I don't understand what you mean by this ^

knocte avatar Apr 08 '20 14:04 knocte

So the thing to ensure is that the right build flags are getting set.

Sorry, what build flags? If this behaviour is based on build flags, then this is actually the culprit. SharpRaven should detect, at runtime, not at compile time, in which environment it's on.

knocte avatar Apr 08 '20 15:04 knocte

I will try building on Windows and testing that build on mono.

Don't try that yet. You have to try with the 2.4.0 nuget but if with I have also tried with the released 2.4.0 dll you mean that you already tried this, then we have to figure out a way for you to reproduce it first, I don't think it's wise to waste time now trying to build anything if you haven't reproed the problem with the nuget binary yet. Please clarify.

knocte avatar Apr 08 '20 15:04 knocte

you mean that you already tried this

yes

what build flags?

if you look at Device.cs, it only calls into InteropServices.RuntimeInformation if the preprocessor flag HAS_RUNTIME_INFORMATION is set.

ysangkok avatar Apr 08 '20 15:04 ysangkok

if you look at Device.cs, it only calls into InteropServices.RuntimeInformation if the preprocessor flag HAS_RUNTIME_INFORMATION is set.

Ok, this means that the environment where SharpRaven's nuget package is built, that build flag is defined, so?

Not sure what you're getting at. I don't think you can work on this problem until you've reproduced it with the nuget pkg. Did you try console-frontend or GTK? if the former, try the latter.

knocte avatar Apr 08 '20 15:04 knocte

you mean that you already tried this

yes

rereading your messages, it seems you have only tried running unit tests? please try the real thing, running geewallet (first console frontend, if that doesn't bomb, try the GTK frontend after)

knocte avatar Apr 08 '20 16:04 knocte

which mono version are you testing with?

ysangkok avatar Apr 08 '20 16:04 ysangkok

which mono version are you testing with?

Mono 6.6.0.161, as said in https://github.com/getsentry/raven-csharp/issues/278#issuecomment-566685634

My gut feeling is that the way to fix this is something like this diff that I'm just creating by hand:

-#if HAS_RUNTIME_INFORMATION
-                   // x-plat: Known results: X86, X64, Arm, Arm64,
-                   RuntimeInformation.OSArchitecture.ToString();
-#elif NET35
-                   // Windows: Known results: AMD64, IA64, x86
-                   Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine)
-                       ?? ProcessorArchitectureNet35();
-#else
-                   // https://github.com/mono/mono/blob/cdea795c0e4706abee0841174c35799690f63ccb/mcs/class/corlib/System.Runtime.InteropServices.RuntimeInformation/RuntimeInformation.cs#L79
-                   Environment.Is64BitOperatingSystem ? "X64" : "X86";
-#endif
+                   try {
+                       RuntimeInformation.OSArchitecture.ToString();
+                   } catch {
+                       if (Path.DirectorySeparatorChar == '\') {
+                           Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine)
+                               ?? ProcessorArchitectureNet35();
+                       } else {
+                            Environment.Is64BitOperatingSystem ? "X64" : "X86";
+                       }
+                   }

knocte avatar Apr 08 '20 16:04 knocte