getsentry / sentry-xamarin

Sentry for Xamarin Native and Xamarin.Forms
https://docs.sentry.io/platforms/dotnet/guides/xamarin/
44 stars 11 forks source link

Crash on Self Hosted. #124

Closed lucas-zimerman closed 1 year ago

lucas-zimerman commented 1 year ago

Received the following crash on Discord.

android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Text.RegularExpressions.RegexReplacement.GetOrCreate (System.WeakReference`1[T] replRef, System.String replacement, System.Collections.Hashtable caps, System.Int32 capsize, System.Collections.Hashtable capnames, System.Text.RegularExpressions.RegexOptions roptions) [0x0000a] in <1b04d5b344b0488d9aaff74f2097c9b3>:0 
  at System.Text.RegularExpressions.Regex.Replace (System.String input, System.String replacement, System.Int32 count, System.Int32 startat) [0x0001c] in <1b04d5b344b0488d9aaff74f2097c9b3>:0 
  at System.Text.RegularExpressions.Regex.Replace (System.String input, System.String replacement) [0x00023] in <1b04d5b344b0488d9aaff74f2097c9b3>:0 
  at System.Text.RegularExpressions.Regex.Replace (System.String input, System.String pattern, System.String replacement, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) [0x0000a] in <1b04d5b344b0488d9aaff74f2097c9b3>:0 
  at System.Text.RegularExpressions.Regex.Replace (System.String input, System.String pattern, System.String replacement) [0x00000] in <1b04d5b344b0488d9aaff74f2097c9b3>:0 
  at Sentry.SentryXamarinOptionsExtensions.AdjustSaasDsn (Sentry.SentryXamarinOptions options) [0x00012] in <e6a9bcafdfbc4cdc9d4d84366dd13354>:0 
  at Sentry.SentryXamarinOptionsExtensions.ConfigureSentryXamarinOptions (Sentry.SentryXamarinOptions options) [0x00020] in <e6a9bcafdfbc4cdc9d4d84366dd13354>:0 
  at Sentry.SentryXamarin.Init (System.Action`1[T] configureOptions) [0x00049] in <e6a9bcafdfbc4cdc9d4d84366dd13354>:0 
  at app.Core.Services.LogService.Initialize () [0x00009] in <841070361d5a47c0a1e93a7a6a485a40>:0 
  at app.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) <0x73a09da43740 + 0x00020> in <860c461873164fd88d82e1688e855de7>:0 
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) <0x73a09a4b4c20 + 0x00046> in <50457d9ca08e4fbaa911ba6cc680a33d>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.26(intptr,intptr,intptr)
    at crc64dfe73796748a91b3.MainActivity.n_onCreate(Native Method)
    at crc64dfe73796748a91b3.MainActivity.onCreate(Unknown Source:0)
    at android.app.Activity.performCreate(Activity.java:8285)
    at android.app.Activity.performCreate(Activity.java:8264)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1384)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3682)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3838)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2309)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7910)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Seems to run on the latest version of the SDK, Ideally the app should not crash when parsing the DSN..................................

lucas-zimerman commented 1 year ago

I am closing this since it was not possible to replicate it. It seems like the NullException happens inside of RegularExpressions.RegexReplacement.GetOrCreate, the is not null, otherwise another error message/stacktrace would appear.

It may be related to a specific version of Visual Studio/Mono that contains some code that could generate an error inside of regex, but all I found was related to an old issue: https://github.com/dotnet/runtime/issues/30362