swift_release_dealloc () causes random and systematic crash

Hello,

It's been more than three weeks that i've been freaking out about this crash that occurs while establishing a BLE connection to a peripheral, scan wifi networks and connect to one of them via BLE.

Here is the crash's stacktrace and I hope that I can get some help in order to resolve this ungoing crash :

+0x284	mov                 x2, x22
+0x288	mov                 x3, x28
+0x28c	bl                  "swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::resize(swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::IndexStorage, unsigned char, MallocTypeCacheEntry*)"
+0x290	mov                 x23, x0
+0x294	add                 x0, sp, #0x2c
+0x298	mov                 x1, x23
+0x29c	mov                 x2, x24
+0x2a0	mov                 x3, x28
+0x2a4	bl                  "std::__1::pair<MallocTypeCacheEntry*, unsigned int> swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::find<unsigned int>(unsigned int const&, swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::IndexStorage, unsigned long, MallocTypeCacheEntry*)"
+0x2a8	and                 x26, x1, #0xffffffff
+0x2ac	cbnz                x27, "_swift_allocObject_+0x2bc"
+0x2b0	b                   "_swift_allocObject_+0x2cc"
+0x2b4	mov                 x26, x1
+0x2b8	cbz                 x27, "_swift_allocObject_+0x2cc"
+0x2bc	ldr                 w8, [x27]
+0x2c0	mov                 x22, x27
+0x2c4	cmp                 w24, w8
+0x2c8	b.lo                "_swift_allocObject_+0x358"
+0x2cc	add                 x8, x24, x24, lsr #2
+0x2d0	add                 x9, x24, #0x1
+0x2d4	cmp                 x8, x9
+0x2d8	csinc               x8, x8, x24, hi
+0x2dc	lsl                 x8, x8, #3
+0x2e0	add                 x0, x8, #0x8
+0x2e4	bl                  "DYLD-STUB$$malloc_good_size"
+0x2e8	mov                 x28, x0
+0x2ec	mov                 w1, #0xb407
+0x2f0	movk                w1, #0x5640, lsl #16
+0x2f4	bl                  "0x1a255c690"
+0x2f8	cbz                 x0, "_swift_allocObject_+0x49c"
+0x2fc	mov                 x22, x0
+0x300	mov                 x8, #0x7fffffff8
+0x304	add                 x8, x28, x8
+0x308	lsr                 x8, x8, #3
+0x30c	str                 w8, [x0]
+0x310	cbz                 x27, "_swift_allocObject_+0x34c"
+0x314	add                 x0, x22, #0x8
+0x318	lsl                 x2, x24, #3
+0x31c	mov                 x1, x25
+0x320	bl                  "DYLD-STUB$$memcpy"
+0x324	mov                 w0, #0x10
+0x328	mov                 x1, #0x3c70
+0x32c	movk                x1, #0xaff9, lsl #16
+0x330	movk                x1, #0x80, lsl #32
+0x334	movk                x1, #0xa, lsl #48
+0x338	bl                  "0x1a255c690"
+0x33c	adrp                x8, 403725                      ; 0x6290d000
+0x340	ldr                 x9, [x8, #0xdf8]
+0x344	stp                 x9, x27, [x0]
+0x348	str                 x0, [x8, #0xdf8]
+0x34c	adrp                x8, 403725                      ; 0x6290d000
+0x350	add                 x8, x8, #0xde0
+0x354	stlr                x22, [x8]
+0x358	add                 x8, x22, x24, lsl #3
+0x35c	ldp                 x10, x22, [sp, #0x8]
+0x360	mov                 x9, x22
+0x364	bfi                 x9, x21, #32, #32
+0x368	str                 x9, [x8, #0x8]
+0x36c	stlr                w10, [x20]
+0x370	and                 x8, x26, #0xffffffff
+0x374	and                 w16, w23, #0x3
+0x378	ldp                 x26, x25, [sp, #0x18]
+0x37c	cmp                 x16, #0x3
+0x380	csel                x16, x16, xzr, ls
+0x384	adrp                x17, 0                          ; 0x0
+0x388	add                 x17, x17, #0x6cc
+0x38c	ldrsw               x16, [x17, x16, lsl #2]
+0x390	adr                 x17, #0x0
+0x394	add                 x16, x17, x16
+0x398	br                  x16
+0x39c	lsl                 x8, x8, #2
+0x3a0	lsl                 x8, x10, x8
+0x3a4	orr                 x8, x8, x23
+0x3a8	adrp                x9, 403725                      ; 0x6290d000
+0x3ac	add                 x9, x9, #0xde8
+0x3b0	stlr                x8, [x9]
+0x3b4	b                   "_swift_allocObject_+0x3fc"
+0x3b8	and                 x9, x23, #0xfffffffffffffffc
+0x3bc	tst                 x23, #0x3
+0x3c0	csel                x9, xzr, x9, eq
+0x3c4	add                 x8, x9, x8
+0x3c8	stlrb               w10, [x8]
+0x3cc	b                   "_swift_allocObject_+0x3fc"
+0x3d0	and                 x9, x23, #0xfffffffffffffffc
+0x3d4	tst                 x23, #0x3
+0x3d8	csel                x9, xzr, x9, eq
+0x3dc	add                 x8, x9, x8, lsl #1
+0x3e0	stlrh               w10, [x8]
+0x3e4	b                   "_swift_allocObject_+0x3fc"
+0x3e8	and                 x9, x23, #0xfffffffffffffffc
+0x3ec	tst                 x23, #0x3
+0x3f0	csel                x9, xzr, x9, eq
+0x3f4	add                 x8, x9, x8, lsl #2
+0x3f8	stlr                w10, [x8]
+0x3fc	dmb                 ish
+0x400	adrp                x8, 403725                      ; 0x6290d000
+0x404	ldr                 w8, [x8, #0xdd8]
+0x408	cbnz                w8, "_swift_allocObject_+0x438"
+0x40c	adrp                x8, 403725                      ; 0x6290d000
+0x410	ldr                 x23, [x8, #0xdf8]
+0x414	cbz                 x23, "_swift_allocObject_+0x430"
+0x418	ldp                 x20, x0, [x23]
+0x41c	bl                  "DYLD-STUB$$free"
+0x420	mov                 x0, x23
+0x424	bl                  "DYLD-STUB$$free"
+0x428	mov                 x23, x20
+0x42c	cbnz                x20, "_swift_allocObject_+0x418"
+0x430	adrp                x8, 403725                      ; 0x6290d000
+0x434	str                 xzr, [x8, #0xdf8]
+0x438	adrp                x0, 403725                      ; 0x6290d000
+0x43c	add                 x0, x0, #0xdf0
+0x440	bl                  "0x1a255c9f0"
+0x444	bfi                 x22, x21, #32, #32
+0x448	mov                 x0, x26
+0x44c	mov                 x1, x25
+0x450	mov                 x2, x22
+0x454	bl                  "swift::swift_slowAllocTyped(unsigned long, unsigned long, unsigned long long)"
+0x458	cbz                 x19, "_swift_allocObject_+0x470"
+0x45c	mov                 x16, x0
+0x460	movk                x16, #0x6ae1, lsl #48
+0x464	mov                 x17, x19
+0x468	pacda               x17, x16
+0x46c	b                   "_swift_allocObject_+0x474"
+0x470	mov                 x17, #0x0
+0x474	mov                 w8, #0x3
+0x478	stp                 x17, x8, [x0]
+0x47c	ldp                 x29, x30, [sp, #0x80]
+0x480	ldp                 x20, x19, [sp, #0x70]
+0x484	ldp                 x22, x21, [sp, #0x60]
+0x488	ldp                 x24, x23, [sp, #0x50]
+0x48c	ldp                 x26, x25, [sp, #0x40]
+0x490	ldp                 x28, x27, [sp, #0x30]
+0x494	add                 sp, sp, #0x90
+0x498	retab
+0x49c	bl                  "_swift_allocObject_.cold.1"

# Platform: apple
# Version: 1.1 (1.9)
# Issue: 412239cf1ac3c946eb36a0f8fcd03787
# Session: 411b37f768814760898b918fa9d8c1b3_DNE_0_v2
# Date: Wed Apr 17 2024 08:14:28 GMT+0200 (heure d’été d’Europe centrale)

com.apple.main-thread
0  libsystem_kernel.dylib         0x1af8 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x1890 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x17a8 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x15e8 mach_msg + 24
4  CoreFoundation                 0x3601c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x33f04 __CFRunLoopRun + 1208
6  CoreFoundation                 0x33968 CFRunLoopRunSpecific + 608
7  GraphicsServices               0x34e0 GSEventRunModal + 164
8  UIKitCore                      0x22aedc -[UIApplication _run] + 888
9  UIKitCore                      0x22a518 UIApplicationMain + 340
10 Vattenfall                     0xb4ec main + 20 (AppDelegate.swift:20)
11 ???                            0x1b33d6d84 (Manquant)

com.apple.uikit.eventfetch-thread
0  libsystem_kernel.dylib         0x1af8 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x1890 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x17a8 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x15e8 mach_msg + 24
4  CoreFoundation                 0x3601c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x33f04 __CFRunLoopRun + 1208
6  CoreFoundation                 0x33968 CFRunLoopRunSpecific + 608
7  Foundation                     0x2b4a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0x554e8 -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9  UIKitCore                      0x18dac8 -[UIEventFetcher threadMain] + 420
10 Foundation                     0x9ca9c __NSThread__start__ + 732
11 libsystem_pthread.dylib        0x2a90 _pthread_start + 136
12 libsystem_pthread.dylib        0x1fcc thread_start + 8

com.google.firebase.crashlytics.MachExceptionServer
0  FirebaseCrashlytics            0x1ef18 FIRCLSProcessRecordAllThreads + 184
1  FirebaseCrashlytics            0x1f2f8 FIRCLSProcessRecordAllThreads + 1176
2  FirebaseCrashlytics            0x16598 FIRCLSHandler + 48
3  FirebaseCrashlytics            0x18d58 FIRCLSMachExceptionServer + 688
4  libsystem_pthread.dylib        0x2a90 _pthread_start + 136
5  libsystem_pthread.dylib        0x1fcc thread_start + 8

com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x1af8 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x1890 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x17a8 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x15e8 mach_msg + 24
4  CoreFoundation                 0x3601c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x33f04 __CFRunLoopRun + 1208
6  CoreFoundation                 0x33968 CFRunLoopRunSpecific + 608
7  CFNetwork                      0x25ac48 estimatedPropertyListSize + 38228
8  Foundation                     0x9ca9c __NSThread__start__ + 732
9  libsystem_pthread.dylib        0x2a90 _pthread_start + 136
10 libsystem_pthread.dylib        0x1fcc thread_start + 8

Thread
0  libsystem_kernel.dylib         0xa084 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x1f6c _pthread_wqthread + 364
2  libsystem_pthread.dylib        0x1fc0 start_wqthread + 8

Crashed: ZuluCalendar
0  libswiftCore.dylib             0x4065e4 swift_isUniquelyReferenced_nonNull_native + 48
1  Foundation                     0x2e75c specialized Set._Variant.insert(_:) + 204
2  Foundation                     0x2e8de4 _fromNSCalendarUnits(_:) + 176
3  Foundation                     0x2e410 _NSSwiftCalendar._components(_:from:) + 60
4  Foundation                     0x2e274 @objc _NSSwiftCalendar._components(_:from:) + 80
5  CoreFoundation                 0xc4e08 CFCalendarDecomposeAbsoluteTime + 348
6  Security                       0x11df64 __SecAbsoluteTimeGetGregorianDate_block_invoke + 64
7  libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
8  libdispatch.dylib              0x132c4 _dispatch_lane_barrier_sync_invoke_and_complete + 56
9  Security                       0xaf0c SecCFCalendarDoWithZuluCalendar + 128
10 Security                       0x7ad4 der_encode_generalizedtime_body_repair + 232
11 Security                       0x76ac der_encode_plist_repair + 468
12 Security                       0x7560 der_encode_plist_repair + 136
13 Security                       0x7560 der_encode_plist_repair + 136
14 Security                       0x740c add_sequence_to_array + 136
15 CoreFoundation                 0x2507c -[__NSDictionaryM __apply:context:] + 128
16 Security                       0x13b80 der_encode_dictionary_repair + 124
17 Security                       0x740c add_sequence_to_array + 136
18 CoreFoundation                 0x2507c -[__NSDictionaryM __apply:context:] + 128
19 Security                       0x13b80 der_encode_dictionary_repair + 124
20 Security                       0x7560 der_encode_plist_repair + 136
21 Security                       0x740c add_sequence_to_array + 136
22 CoreFoundation                 0x2507c -[__NSDictionaryM __apply:context:] + 128
23 Security                       0x13b80 der_encode_dictionary_repair + 124
24 Security                       0xcc2c CFPropertyListCreateDERData + 100
25 Security                       0xcb78 SecTrustSerialize + 216
26 CFNetwork                      0x1ef68 _CFNetworkSetHSTSStoragePath + 93612
27 CFNetwork                      0xab3ac CFURLDownloadStart + 74768
28 CFNetwork                      0xaaedc CFURLDownloadStart + 73536
29 CFNetwork                      0xbc780 CFURLDownloadStart + 145380
30 CFNetwork                      0x1da190 CFHTTPCookieStorageUnscheduleFromRunLoop + 158916
31 CFNetwork                      0xbaa64 CFURLDownloadStart + 137928
32 libboringssl.dylib             0x3b638 __boringssl_context_evaluate_trust_async_external_block_invoke + 448
33 libdispatch.dylib              0x213c _dispatch_call_block_and_release + 32
34 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
35 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain + 748
36 libdispatch.dylib              0xbf64 _dispatch_lane_invoke + 432
37 libdispatch.dylib              0xd284 _dispatch_workloop_invoke + 1756
38 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 288
39 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread + 404
40 libsystem_pthread.dylib        0x1f20 _pthread_wqthread + 288
41 libsystem_pthread.dylib        0x1fc0 start_wqthread + 8

This crash occurs only on iOS 17.xx

swift_release_dealloc () causes random and systematic crash
 
 
Q