Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

DllNotFoundExceptions and SecurityException when using with Mono #278

Open
knocte opened this issue Nov 14, 2018 · 32 comments
Open

DllNotFoundExceptions and SecurityException when using with Mono #278

knocte opened this issue Nov 14, 2018 · 32 comments
Labels

Comments

@knocte
Copy link

knocte commented Nov 14, 2018

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 
@bruno-garcia
Copy link
Member

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:

if (runtime.IsNetFx())
{
runtime.Build = Get45PlusLatestInstallationFromRegistry()?.ToString();
}

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

@knocte
Copy link
Author

knocte commented Nov 15, 2019

I guess I haven't seen this again.

@bruno-garcia
Copy link
Member

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

@knocte
Copy link
Author

knocte commented Nov 15, 2019

What are the reasons not to?

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

@knocte
Copy link
Author

knocte commented Nov 15, 2019

@bruno-garcia
Copy link
Member

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

@knocte
Copy link
Author

knocte commented Nov 15, 2019

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.

@bruno-garcia
Copy link
Member

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.

@knocte
Copy link
Author

knocte commented Dec 17, 2019

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
Copy link
Author

knocte commented Dec 17, 2019

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
Copy link
Author

knocte commented Dec 17, 2019

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 ()

@bruno-garcia
Copy link
Member

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:

#if NET45PLUS_REGISTRY_VERSION // .NET Framework 4.5 and later
if (runtime.IsNetFx())
{
runtime.Build = Get45PlusLatestInstallationFromRegistry()?.ToString();
}
#endif

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

public static Runtime Create()
{
try
{
return RuntimeInfoHelper.GetRuntime();
}
catch (Exception e)
{
SystemUtil.WriteError(e);
return null;
}

@knocte
Copy link
Author

knocte commented Dec 17, 2019

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.

@bruno-garcia
Copy link
Member

@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
Copy link
Member

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

@knocte
Copy link
Author

knocte commented Dec 18, 2019

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

@knocte
Copy link
Author

knocte commented Feb 17, 2020

@bruno-garcia can you reopen this please?

@bruno-garcia bruno-garcia reopened this Feb 17, 2020
@bruno-garcia
Copy link
Member

bruno-garcia commented Feb 17, 2020

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?

@ysangkok
Copy link

ysangkok commented Apr 7, 2020

@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?

@knocte
Copy link
Author

knocte commented Apr 8, 2020

@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
Copy link
Author

knocte commented Apr 8, 2020

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?

@ysangkok
Copy link

ysangkok commented Apr 8, 2020

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.

@knocte
Copy link
Author

knocte commented Apr 8, 2020

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
Copy link
Author

knocte commented Apr 8, 2020

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
Copy link
Author

knocte commented Apr 8, 2020

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.

@ysangkok
Copy link

ysangkok commented Apr 8, 2020

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.

@knocte
Copy link
Author

knocte commented Apr 8, 2020

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
Copy link
Author

knocte commented Apr 8, 2020

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)

@ysangkok
Copy link

ysangkok commented Apr 8, 2020

which mono version are you testing with?

@knocte
Copy link
Author

knocte commented Apr 8, 2020

which mono version are you testing with?

Mono 6.6.0.161, as said in #278 (comment)

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";
+                       }
+                   }

@ysangkok
Copy link

ysangkok commented Apr 15, 2020 via email

@knocte
Copy link
Author

knocte commented Apr 15, 2020

giving on up compile time flags altogether.

Why do you think compile time flags are important? The nuget is built in some cloud computer we don't know/care about, and then that binary is the one consumed by all the platforms; therefore these kind of checks have to be done at runtime, not at compile time.

While it might work, it is changing a major component of how the library works, and should be done consistently across the whole codebase instead of just here.

This library is deprecated, so no big changes are going to be allowed. I say we apply this patch for the case we know it's crashing for us.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants