Crash inside a try/catch block

rnuryapici 6 Reputation points
2021-05-18T07:02:57.82+00:00

I see 8.2K events from 1.2K users in Firebase Console for my iOS application (last 90 days). As I inspected the problem, the line where crash occurs is inside a try/catch block.
Statistically almost every user has probably seen this issue, but I never experienced any crashes while developing or trying to reproduce this crash. This crash hasn't seen in my Android application.

So, I'm wondering how is it possible to crash inside a try/catch block? Or is it possible to firebase logs non-fatal exceptions for iOS and shows as crashes?

Crashes at line 22.

try   
{   
    var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();   
    var settings = new JsonSerializerSettings   
    {   
        NullValueHandling = NullValueHandling.Ignore,   
        MissingMemberHandling = MissingMemberHandling.Ignore   
    };   
    response.statusCode = httpResponseMessage.StatusCode;   
    if (httpResponseMessage.IsSuccessStatusCode)   
    {   
        var result = JsonConvert.DeserializeObject<T>(jsonString, settings);   
        response.Response = JsonConvert.DeserializeObject<T>(jsonString, settings);   
    }   
    else if (httpResponseMessage.StatusCode == HttpStatusCode.BadRequest   
         || httpResponseMessage.StatusCode == HttpStatusCode.InternalServerError   
         || httpResponseMessage.StatusCode == HttpStatusCode.Forbidden   
         || httpResponseMessage.StatusCode == HttpStatusCode.ServiceUnavailable   
         || httpResponseMessage.StatusCode == HttpStatusCode.Unauthorized)   
    {   
        var error = JsonConvert.DeserializeObject<ErrorMessageModel>(jsonString, settings);   
        response.ErrorCode = error.ErrorCode;   
        response.ErrorMessage = error.ErrorMessage;   
        return response;   
    }   

    return response;   
}   
catch (JsonException)   
{   
    return await this.PopulateResponse<T>(httpResponseMessage, true, ++count);   
}   
catch (Exception)   
{   
    return response;   
}   

Stacktrace of this crash from Firebase is below.
BaseClient line 70 corresponds that code block's line 21
BaseClient line 71 corresponds that code block's line 22

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
Crashed: tid_407

0x10461d6a8 ut_end + 71 (BaseClient.cs:71)
0x10461d69c ut_end + 68 (BaseClient.cs:70)
0x1032872b0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 4341641904
0x10592eb54 mono_jit_runtime_invoke + 3165 (mini-runtime.c:3165)
0x1059ea278 mono_runtime_invoke_checked + 3052 (object.c:3052)
0x105913b04 mono_gsharedvt_constrained_call + 1429 (jit-icalls.c:1429)
0x10328c440 wrapper_managed_to_native_object___icall_wrapper_mono_gsharedvt_constrained_call_intptr_intptr_intptr_intptr_intptr + 4341662784
0x1031cbf94 System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_TResult_GSHAREDVT_Start_TStateMachine_GSHAREDVT_TStateMachine_GSHAREDVT_ + 4340875156
0x10461d180 VXXXC_Services_BaseClient_PopulateResponse_T_REF_System_Net_Http_HttpResponseMessage_bool_int + 4362178944
0x10463fb44 VXXXC_Services_Services_VehicleService__GetDefaultUserVehicled__6_MoveNext + 132 (VehicleService.cs:132)
0x10307109c System_Runtime_CompilerServices_AsyncMethodBuilderCore_MoveNextRunner_InvokeMoveNext_object + 4339454108
0x102ff661c System_Threading_ExecutionContext_RunInternal_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 4338951708
0x102ff641c System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 4338951196
0x103070f58 System_Runtime_CompilerServices_AsyncMethodBuilderCore_MoveNextRunner_Run + 4339453784
0x103014498 System_Threading_Tasks_SynchronizationContextAwaitTaskContinuation__c___cctorb__7_0_object + 4339074200
0x103eaafcc Foundation_NSAsyncSynchronizationContextDispatcher_Apply + 178 (NSAction.cs:178)
0x1032872b0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 4341641904
0x10592eb54 mono_jit_runtime_invoke + 3165 (mini-runtime.c:3165)
0x1059ea278 mono_runtime_invoke_checked + 3052 (object.c:3052)
0x1059edadc mono_runtime_invoke + 3107 (object.c:3107)
0x102e9a8b0 native_to_managed_trampoline_10(objc_object*, objc_selector*, _MonoMethod**, unsigned int) + 400 (registrar.m:400)
0x102ea2e3c -[__MonoMac_NSAsyncSynchronizationContextDispatcher xamarinApplySelector] + 9890 (registrar.m:9890)
0x195473b90 __NSThreadPerformPerform + 188
0x19405976c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
0x194059668 __CFRunLoopDoSource0 + 208
0x194058960 __CFRunLoopDoSources0 + 268
0x194052a8c __CFRunLoopRun + 824
0x19405221c CFRunLoopRunSpecific + 600
0x1abc1c784 GSEventRunModal + 164
0x196a92ee8 -[UIApplication _run] + 1072
0x196a9875c UIApplicationMain + 168
0x103f18b18 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 4354820888
0x103e59860 UIKit_UIApplication_Main_string___intptr_intptr + 86 (UIApplication.cs:86)
0x103e597e4 UIKit_UIApplication_Main_string___string_string + 66 (UIApplication.cs:66)
0x102ee76e4 VXXXC_iOS_Application_Main_string__ + 1 (<unknown>:1)
0x1032872b0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 4341641904
0x10592eb54 mono_jit_runtime_invoke + 3165 (mini-runtime.c:3165)
0x1059ea278 mono_runtime_invoke_checked + 3052 (object.c:3052)
0x1059f04d0 mono_runtime_exec_main_checked + 5178 (object.c:5178)
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,380 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.