usabilla-u4a-ios-swift-sdk icon indicating copy to clipboard operation
usabilla-u4a-ios-swift-sdk copied to clipboard

Crash logs with AppCrash.swift

Open dyang opened this issue 2 years ago • 5 comments

Hi,

I'm working on an app that uses Usabilla 6.12.0. Recently I'm starting to see crashes that point to AppCrash.RecieveSignal. e.g.

Crashed: com.apple.NSURLSession-work
0  libsystem_platform.dylib       0x60bc _os_unfair_lock_recursive_abort + 36
1  libsystem_platform.dylib       0xa18 _os_unfair_lock_lock_slow + 280
2  libsystem_malloc.dylib         0x3c40 tiny_malloc_should_clear + 152
3  libsystem_malloc.dylib         0x6e24 szone_malloc_should_clear + 80
4  libsystem_malloc.dylib         0x6024 _malloc_zone_malloc + 156
5  libswiftCore.dylib             0x39a054 swift_slowAlloc + 64
6  libswiftCore.dylib             0x39a250 swift_allocObject + 64
7  libswiftFoundation.dylib       0x3b194 _ContiguousArrayBuffer._consumeAndCreateNew(bufferIsUnique:minimumCapacity:growForAppend:) + 204
8  libswiftFoundation.dylib       0x1b868 ContiguousArray._createNewBuffer(bufferIsUnique:minimumCapacity:growForAppend:) + 76
9  libswiftFoundation.dylib       0x3ac4 specialized _arrayForceCast<A, B>(_:) + 296
10 libswiftFoundation.dylib       0x398c static Array._unconditionallyBridgeFromObjectiveC(_:) + 272
11 Usabilla                       0x126dc4 closure #1 in variable initialization expression of static AppCrash.RecieveSignal + 154 (AppCrash.swift:154)
12 libsystem_platform.dylib       0x1c10 _sigtramp + 56
13 libsystem_pthread.dylib        0x73bc pthread_kill + 268
14 libsystem_c.dylib              0x20524 abort + 168
15 libsystem_malloc.dylib         0x1ca04 _malloc_put + 550
16 libsystem_malloc.dylib         0x1cc9c malloc_zone_error + 100
17 libsystem_malloc.dylib         0x1c790 free_list_checksum_botch + 40
18 libsystem_malloc.dylib         0x3848 tiny_malloc_from_free_list + 1820
19 libsystem_malloc.dylib         0x3c84 tiny_malloc_should_clear + 220
20 libsystem_malloc.dylib         0x6e24 szone_malloc_should_clear + 80
21 libsystem_malloc.dylib         0x4e5c _malloc_zone_calloc + 88
22 libobjc.A.dylib                0x5410 _objc_rootAllocWithZone + 40
23 CFNetwork                      0x71e7c _CFURLStorageSessionCopyCache + 9232
24 CFNetwork                      0x5b74c CFHTTPCookieStorageCopyCookies + 11748
25 CFNetwork                      0x4d088 CFURLCacheRemoveAllCachedResponses + 12616
26 CFNetwork                      0xa450 CFHTTPCookieCopyDomain + 2040
27 CFNetwork                      0x1f4f0 CFHTTPCookieCopyRequestHeaderFields + 1040
28 libdispatch.dylib              0x12830 _dispatch_block_async_invoke2 + 148
29 libdispatch.dylib              0x3a30 _dispatch_client_callout + 20
30 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
31 libdispatch.dylib              0xbcb4 _dispatch_lane_invoke + 444
32 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
33 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
34 libsystem_pthread.dylib        0xe5c start_wqthread + 8

Here's another crash:

Crashed: com.apple.CFNetwork.Connection
0  libsystem_platform.dylib       0x60bc _os_unfair_lock_recursive_abort + 36
1  libsystem_platform.dylib       0xa18 _os_unfair_lock_lock_slow + 280
2  libsystem_malloc.dylib         0x3c40 tiny_malloc_should_clear + 152
3  libsystem_malloc.dylib         0x6e24 szone_malloc_should_clear + 80
4  libsystem_malloc.dylib         0x6024 _malloc_zone_malloc + 156
5  libswiftCore.dylib             0x39a054 swift_slowAlloc + 64
6  libswiftCore.dylib             0x39a250 swift_allocObject + 64
7  libswiftFoundation.dylib       0x3b194 _ContiguousArrayBuffer._consumeAndCreateNew(bufferIsUnique:minimumCapacity:growForAppend:) + 204
8  libswiftFoundation.dylib       0x1b868 ContiguousArray._createNewBuffer(bufferIsUnique:minimumCapacity:growForAppend:) + 76
9  libswiftFoundation.dylib       0x3ac4 specialized _arrayForceCast<A, B>(_:) + 296
10 libswiftFoundation.dylib       0x398c static Array._unconditionallyBridgeFromObjectiveC(_:) + 272
11 Usabilla                       0x126dc4 closure #1 in variable initialization expression of static AppCrash.RecieveSignal + 154 (AppCrash.swift:154)
12 libsystem_platform.dylib       0x1c10 _sigtramp + 56
13 libsystem_pthread.dylib        0x73bc pthread_kill + 268
14 libsystem_c.dylib              0x20524 abort + 168
15 libsystem_malloc.dylib         0x1ca04 _malloc_put + 550
16 libsystem_malloc.dylib         0x1cc9c malloc_zone_error + 100
17 libsystem_malloc.dylib         0x1c790 free_list_checksum_botch + 40
18 libsystem_malloc.dylib         0x3848 tiny_malloc_from_free_list + 1820
19 libsystem_malloc.dylib         0x3c84 tiny_malloc_should_clear + 220
20 libsystem_malloc.dylib         0x6e24 szone_malloc_should_clear + 80
21 libsystem_malloc.dylib         0x4e5c _malloc_zone_calloc + 88
22 libobjc.A.dylib                0x2a1c class_createInstance + 64
23 libnetwork.dylib               0x5e284c nw_protocol_metadata_create_singleton + 188
24 libquic.dylib                  0xf220 quic_alloc_stream + 288
25 libnetwork.dylib               0x40298 nw_protocol_implementation_add_input_handler + 3632
26 libnetwork.dylib               0x68dfdc nw_endpoint_handler_register_context_internal + 448
27 libnetwork.dylib               0x697a24 nw_endpoint_handler_add_write_request + 1404
28 libnetwork.dylib               0x6e1a30 nw_connection_add_write_request_on_queue + 160
29 libnetwork.dylib               0x6e1928 nw_connection_add_write_request + 272
30 libnetwork.dylib               0x6e0de4 nw_connection_send + 224
31 CFNetwork                      0x110cc4 CFURLDownloadCancel + 50188
32 CFNetwork                      0x13b5bc _CFNetworkErrorGetLocalizedDescription + 30760
33 CFNetwork                      0x13b424 _CFNetworkErrorGetLocalizedDescription + 30352
34 CFNetwork                      0xbb438 CFURLCredentialStorageSetDefaultCredentialForProtectionSpace + 9128
35 CFNetwork                      0xbb394 CFURLCredentialStorageSetDefaultCredentialForProtectionSpace + 8964
36 CFNetwork                      0xba934 CFURLCredentialStorageSetDefaultCredentialForProtectionSpace + 6308
37 CFNetwork                      0xbacb4 CFURLCredentialStorageSetDefaultCredentialForProtectionSpace + 7204
38 CFNetwork                      0xbb23c CFURLCredentialStorageSetDefaultCredentialForProtectionSpace + 8620
39 CFNetwork                      0x138920 _CFNetworkErrorGetLocalizedDescription + 19340
40 CFNetwork                      0x137eec _CFNetworkErrorGetLocalizedDescription + 16728
41 CFNetwork                      0x1116f0 CFURLDownloadCancel + 52792
42 libdispatch.dylib              0x12830 _dispatch_block_async_invoke2 + 148
43 libdispatch.dylib              0x3a30 _dispatch_client_callout + 20
44 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
45 libdispatch.dylib              0xbcb4 _dispatch_lane_invoke + 444
46 libdispatch.dylib              0xcf80 _dispatch_workloop_invoke + 1784
47 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
48 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
49 libsystem_pthread.dylib        0xe5c start_wqthread + 8

So far I haven't found a way to reproduce the crash, and I'm having trouble understanding why there's AppCrash.swift here. Is it a crash handler that Usabilla provides that tries to intercept and respond to app crashes? (I don't see this mentioned anywhere as an Usabilla feature) Should I intercept the above logs as:

  1. app crashed, Usabilla tracked the error?
  2. app crashed, Usabilla tracked the error, but Usabilla also crashed?
  3. Usabilla crashed?

Thanks!

dyang avatar Sep 12 '22 18:09 dyang

Update, here comes a new crash report that has something different:

Crashed: com.apple.CFNetwork.Connection
0  libsystem_platform.dylib       0x60bc _os_unfair_lock_recursive_abort + 36
1  libsystem_platform.dylib       0xa18 _os_unfair_lock_lock_slow + 280
2  libsystem_malloc.dylib         0x3c40 tiny_malloc_should_clear + 152
3  libsystem_malloc.dylib         0x6e24 szone_malloc_should_clear + 80
4  libsystem_malloc.dylib         0x4e5c _malloc_zone_calloc + 88
5  libobjc.A.dylib                0x7470 cache_t::insert(objc_selector*, void (*)(), objc_object*) + 460
6  libobjc.A.dylib                0x6bf0 lookUpImpOrForward + 636
7  libobjc.A.dylib                0x23e4 _objc_msgSend_uncached + 68
8  UIKitCore                      0x1f1890 _updateBatteryStatusBasedOnProperties + 484
9  UIKitCore                      0x5ce3e0 _3rdParty_batteryInformationChanged + 580
10 UIKitCore                      0x4cf448 -[UIDevice setBatteryMonitoringEnabled:] + 1292
11 Usabilla                       0xe9fa8 specialized AppMetaData.init() + 19 (AppMetaData.swift:19)
12 Usabilla                       0x126fa0 closure #1 in variable initialization expression of static AppCrash.RecieveSignal + 4324372384 (<compiler-generated>:4324372384)
13 libsystem_platform.dylib       0x1c10 _sigtramp + 56
14 libsystem_pthread.dylib        0x73bc pthread_kill + 268
15 libsystem_c.dylib              0x20524 abort + 168
16 libsystem_malloc.dylib         0x1ca04 _malloc_put + 550
17 libsystem_malloc.dylib         0x1cc9c malloc_zone_error + 100
18 libsystem_malloc.dylib         0x1c790 free_list_checksum_botch + 40
19 libsystem_malloc.dylib         0x3848 tiny_malloc_from_free_list + 1820
20 libsystem_malloc.dylib         0x3c84 tiny_malloc_should_clear + 220
21 libsystem_malloc.dylib         0x6e24 szone_malloc_should_clear + 80
22 libsystem_malloc.dylib         0x6024 _malloc_zone_malloc + 156
23 CoreFoundation                 0x2b740 _CFRuntimeCreateInstance + 612
24 CFNetwork                      0x7df0c CFURLResponseCreateWithHTTPResponse + 148
25 CFNetwork                      0x1987fc _CFNetworkErrorGetLocalizedDescription + 412264
26 CFNetwork                      0x195d3c _CFNetworkErrorGetLocalizedDescription + 401320
27 CFNetwork                      0x19cd34 _CFNetworkErrorGetLocalizedDescription + 429984
28 CFNetwork                      0x19bab4 _CFNetworkErrorGetLocalizedDescription + 425248
29 CFNetwork                      0x266d5c kCFNIE + 19588
30 CFNetwork                      0x1fece8 _CFNetworkHTTPConnectionCacheGetLimit + 71592
31 CFNetwork                      0x25d6dc __CFNetworkAgentMessageProcessorMain + 125896
32 CFNetwork                      0x25d100 __CFNetworkAgentMessageProcessorMain + 124396
33 libdispatch.dylib              0x1e6c _dispatch_call_block_and_release + 32
34 libdispatch.dylib              0x3a30 _dispatch_client_callout + 20
35 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
36 libdispatch.dylib              0xbcb4 _dispatch_lane_invoke + 444
37 libdispatch.dylib              0xcf80 _dispatch_workloop_invoke + 1784
38 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
39 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
40 libsystem_pthread.dylib        0xe5c start_wqthread + 8

Note the call to UIDevice.setBatteryMonitoringEnabled at line 10. A bit googling suggests that this setBatteryMonitoringEnabled API is not thread safe (link).

Another thought - I can see that our direct calls to Usabilla are all made on the main thread. But by reading the above crash logs I can see that they all happened on non-UI threads. Could it be that Usabilla registers some kind of global event listener and gets invoked on the events' threads?

dyang avatar Sep 13 '22 06:09 dyang

Hi @dyang thanks for reaching out!

This file logs the crash as in Usabilla we have a standard event which tracks the crash and triggers the Campaign on the next launch, based on the crash (if Campaign created for it).

Can you please update to the latest SDK (v6.12.3) and let us know if this resolves the issue?

Thanks in advance :) Emmett

emulroy9 avatar Sep 13 '22 09:09 emulroy9

@emulroy9 Thanks for the info. I'll try v6.12.3 and report back.

When it comes to the standard Usabilla event you mentioned, does it track all crashes, i.e those that are caused by non-Usabilla code? I'm curious because I never saw AppCrash.swift in our crash reports prior to this. :)

dyang avatar Sep 13 '22 10:09 dyang

@dyang no problem at all, thanks :)

The reason for this is that standard events only started from v6.12.0

emulroy9 avatar Sep 13 '22 10:09 emulroy9

Update: We're still seeing crashes after the 6.23.3 upgrade. One type of crash stood up in particular, see the logs below:

Crashed: com.usabilla.u4a.storage
0   libdispatch.dylib              0x12fe8 __DISPATCH_WAIT_FOR_QUEUE__ + 476
1   libdispatch.dylib              0x12b28 _dispatch_sync_f_slow + 144
2   Usabilla                       0xf15dc AppEventNotifier.createJustInTimeEvaluationbject() + 4345550300 (AppEventNotifier.swift:4345550300)
3   Usabilla                       0x12b18c closure #1 in variable initialization expression of static AppCrash.RecieveSignal + 166 (AppEventNotifier.swift:166)
4   libsystem_platform.dylib       0x1c10 _sigtramp + 56
5   libsystem_pthread.dylib        0x73bc pthread_kill + 268
6   libsystem_c.dylib              0x20524 abort + 168
7   libsystem_malloc.dylib         0x1ca04 _malloc_put + 550
8   libsystem_malloc.dylib         0x1cc9c malloc_zone_error + 100
9   libsystem_malloc.dylib         0x170dc nanov2_allocate_from_block + 568
10  libsystem_malloc.dylib         0x16164 nanov2_allocate + 128
11  libsystem_malloc.dylib         0x16750 nanov2_calloc + 160
12  libsystem_malloc.dylib         0x4e5c _malloc_zone_calloc + 88
13  CoreFoundation                 0x2b628 _CFRuntimeCreateInstance + 332
14  CoreFoundation                 0x27838 __CFStringCreateImmutableFunnel3 + 1848
15  CoreFoundation                 0x2dedc CFStringCreateWithBytes + 48
16  Foundation                     0x1bf4c +[NSString stringWithUTF8String:] + 80
17  libswiftCore.dylib             0x1358c _CocoaArrayWrapper.subscript.getter + 56
18  libswiftFoundation.dylib       0x3b00 specialized _arrayForceCast<A, B>(_:) + 356
19  libswiftFoundation.dylib       0x398c static Array._unconditionallyBridgeFromObjectiveC(_:) + 272
20  Usabilla                       0x12acf8 closure #1 in variable initialization expression of static AppCrash.RecieveSignal + 154 (AppCrash.swift:154)
21  libsystem_platform.dylib       0x1c10 _sigtramp + 56
22  libsystem_pthread.dylib        0x73bc pthread_kill + 268
23  libsystem_c.dylib              0x20524 abort + 168
24  libsystem_malloc.dylib         0x1ca04 _malloc_put + 550
25  libsystem_malloc.dylib         0x1cc9c malloc_zone_error + 100
26  libsystem_malloc.dylib         0x170dc nanov2_allocate_from_block + 568
27  libsystem_malloc.dylib         0x16164 nanov2_allocate + 128
28  libsystem_malloc.dylib         0x16750 nanov2_calloc + 160
29  libsystem_malloc.dylib         0x4e5c _malloc_zone_calloc + 88
30  libobjc.A.dylib                0x2a1c class_createInstance + 64
31  CoreFoundation                 0x292e8 __CFAllocateObject + 24
32  CoreFoundation                 0x213f0 __NSDictionaryI_new + 144
33  CoreFoundation                 0x88250 __NSCFDictionaryCreateTransfer + 224
34  CoreFoundation                 0xc75b4 __CFDictionaryCreateTransfer + 64
35  CoreFoundation                 0x1be50 __CFBinaryPlistCreateObjectFiltered + 6832
36  CoreFoundation                 0x1b244 __CFBinaryPlistCreateObjectFiltered + 3748
37  CoreFoundation                 0x1b984 __CFBinaryPlistCreateObjectFiltered + 5604
38  CoreFoundation                 0x10b58 __CFTryParseBinaryPlist + 244
39  CoreFoundation                 0x68370 _CFPropertyListCreateWithData + 164
40  CoreFoundation                 0x6a9cc CFPropertyListCreateWithData + 60
41  Foundation                     0x356b0 +[NSPropertyListSerialization propertyListWithData:options:format:error:] + 56
42  libswiftFoundation.dylib       0xf353c closure #1 in PropertyListDecoder.decode<A>(_:from:format:) + 116
43  libswiftFoundation.dylib       0xf3600 partial apply for closure #1 in PropertyListDecoder.decode<A>(_:from:format:) + 24
44  libswiftObjectiveC.dylib       0x1a10 autoreleasepool<A>(invoking:) + 64
45  libswiftFoundation.dylib       0x2f078 PropertyListDecoder.decode<A>(_:from:format:) + 240
46  libswiftFoundation.dylib       0x28c08 PropertyListDecoder.decode<A>(_:from:) + 72
47  libswiftFoundation.dylib       0x2bd44 dispatch thunk of PropertyListDecoder.decode<A>(_:from:) + 48
48  Usabilla                       0xfe3e0 specialized closure #1 in FileStorageDAO.read(id:) + 65 (FileStorageDAO.swift:65)
49  Usabilla                       0xdda3c thunk for @callee_guaranteed () -> () + 4345469500 (<compiler-generated>:4345469500)
50  Usabilla                       0xdda5c thunk for @escaping @callee_guaranteed () -> () + 4345469532 (<compiler-generated>:4345469532)
51  libdispatch.dylib              0x3a30 _dispatch_client_callout + 20
52  libdispatch.dylib              0x12c90 _dispatch_lane_barrier_sync_invoke_and_complete + 56
53  Usabilla                       0x994d0 specialized FileStorageDAO.readAll() + 62 (FileStorageDAO.swift:62)
54  Usabilla                       0x9989c DefaultEventEngine.triggered(_:evalObject:) + 18 (DefaultEventStore.swift:18)
55  Usabilla                       0x12b1a0 closure #1 in variable initialization expression of static AppCrash.RecieveSignal + 166 (AppEventNotifier.swift:166)
56  libsystem_platform.dylib       0x1c10 _sigtramp + 56
57  libsystem_pthread.dylib        0x73bc pthread_kill + 268
58  libsystem_c.dylib              0x20524 abort + 168
59  libsystem_malloc.dylib         0x1ca04 _malloc_put + 550
60  libsystem_malloc.dylib         0x1cc9c malloc_zone_error + 100
61  libsystem_malloc.dylib         0x170dc nanov2_allocate_from_block + 568
62  libsystem_malloc.dylib         0x16164 nanov2_allocate + 128
63  libsystem_malloc.dylib         0x16750 nanov2_calloc + 160
64  libsystem_malloc.dylib         0x4e5c _malloc_zone_calloc + 88
65  CoreFoundation                 0x2b628 _CFRuntimeCreateInstance + 332
66  CoreFoundation                 0x27838 __CFStringCreateImmutableFunnel3 + 1848
67  CoreFoundation                 0x2dedc CFStringCreateWithBytes + 48
68  Foundation                     0x1bf4c +[NSString stringWithUTF8String:] + 80
69  libswiftCore.dylib             0x1358c _CocoaArrayWrapper.subscript.getter + 56
70  libswiftFoundation.dylib       0x3b00 specialized _arrayForceCast<A, B>(_:) + 356
71  libswiftFoundation.dylib       0x398c static Array._unconditionallyBridgeFromObjectiveC(_:) + 272
72  Usabilla                       0x12acf8 closure #1 in variable initialization expression of static AppCrash.RecieveSignal + 154 (AppCrash.swift:154)
73  libsystem_platform.dylib       0x1c10 _sigtramp + 56
74  libsystem_pthread.dylib        0x73bc pthread_kill + 268
75  libsystem_c.dylib              0x20524 abort + 168
76  libsystem_malloc.dylib         0x1ca04 _malloc_put + 550
77  libsystem_malloc.dylib         0x1cc9c malloc_zone_error + 100
78  libsystem_malloc.dylib         0x170dc nanov2_allocate_from_block + 568
79  libsystem_malloc.dylib         0x16164 nanov2_allocate + 128
80  libsystem_malloc.dylib         0x16080 nanov2_malloc + 64
81  libsystem_malloc.dylib         0x6024 _malloc_zone_malloc + 156
82  CoreFoundation                 0x3f408 __CFStrAllocateMutableContents + 100
83  CoreFoundation                 0x2ef48 __CFStringChangeSizeMultiple + 656
84  CoreFoundation                 0x2387c __CFStringAppendBytes + 672
85  CoreFoundation                 0x8f90 __CFStringAppendFormatCore + 8052
86  CoreFoundation                 0x2898c _CFStringCreateWithFormatAndArgumentsReturningMetadata + 176
87  CoreFoundation                 0x28b64 CFStringCreateWithFormat + 48
88  libnetwork.dylib               0xaf2a8 -[NWConcrete_nw_activity description] + 696
89  Foundation                     0x1c210 _NS_os_log_callback + 284
90  libsystem_trace.dylib          0x7280 _os_log_fmt_flatten_NSCF + 64
91  libsystem_trace.dylib          0x6970 _os_log_fmt_flatten_object + 232
92  libsystem_trace.dylib          0x47d4 _os_log_impl_flatten_and_send + 1856
93  libsystem_trace.dylib          0x2804 _os_log + 152
94  libsystem_trace.dylib          0x7de0 _os_log_impl + 24
95  CFNetwork                      0x155fc CFURLCacheSetMemoryCapacity + 20016
96  <app>                        0x58a0 closure #1 in NSURLSession.data(from:) + 24 (URLSession+Util.swift:24)
97  libswift_Concurrency.dylib     0x68ac partial apply for closure #1 in withCheckedThrowingContinuation<A>(function:_:) + 168
98  libswift_Concurrency.dylib     0x69c0 withUnsafeThrowingContinuation<A>(_:) + 228
99  libswift_Concurrency.dylib     0x3b7cc swift::runJobInEstablishedExecutorContext(swift::Job*) + 244
100 libswift_Concurrency.dylib     0x3c1e8 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 72
101 libdispatch.dylib              0x15164 _dispatch_root_queue_drain + 396
102 libdispatch.dylib              0x1596c _dispatch_worker_thread2 + 164
103 libsystem_pthread.dylib        0x1080 _pthread_wqthread + 228
104 libsystem_pthread.dylib        0xe5c start_wqthread + 8

Note that the crash started from our code (line 96), but then what's strange is the 4 nested calls to AppCrash.RecieveSignal. Could it be that the Usabilla crash event handler crashed in itself?

dyang avatar Sep 19 '22 19:09 dyang