analytics-swift: Crash in Analytics.configuration.getter
Describe the bug
After integrating the Segment SDK in our iOS app, we’ve started seeing a number of crashes in an internal access of Analytics.configuration. This is currently our app’s top crasher, although only a small percentage of users have experienced it.
To Reproduce We haven’t found a way to reproduce this crash, as it seems like it happens under specific timing that is hard to replicate.
The crash seems to always occur a few seconds after launching the app, immediately after a successful /projects/{key}/settings fetch.
Platform:
- Library Version in use: 1.5.0
- Platform being tested: iOS 16 and 17
- Integrations in use: none
Stack Traces There seem to be two common forms of the stack traces for this crash, below is an example of each.
Example 1:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Crashed Thread: 0
Application Specific Information:
Exception 6, Code 1, Subcode 4355499808
Thread 0 Crashed:
0 MyApp 0x1039ba720 [inlined] value
1 MyApp 0x1039ba720 [inlined] Analytics.configuration.getter (Analytics.swift:17)
2 MyApp 0x1039ba720 IntervalBasedFlushPolicy.configure (IntervalBasedFlushPolicy.swift:42)
3 MyApp 0x1039c2950 [inlined] thunk for closure
4 MyApp 0x1039c2950 thunk for closure
5 MyApp 0x1039c697c [inlined] thunk for closure
6 MyApp 0x1039c697c thunk for closure
7 MyApp 0x1039c6a24 [inlined] Store.notify<T> (Store.swift:250)
8 MyApp 0x1039c6a24 Store.notify<T>
9 MyApp 0x1039c4d90 thunk for closure
10 libdispatch.dylib 0x34d4606a4 _dispatch_call_block_and_release
11 libdispatch.dylib 0x34d4622fc _dispatch_client_callout
12 libdispatch.dylib 0x34d470994 _dispatch_main_queue_drain
13 libdispatch.dylib 0x34d4705ac _dispatch_main_queue_callback_4CF
14 CoreFoundation 0x33d523208 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
15 CoreFoundation 0x33d51ff14 __CFRunLoopRun
16 CoreFoundation 0x33d51f664 CFRunLoopRunSpecific
17 GraphicsServices 0x3c3ce55e8 GSEventRunModal
18 UIKitCore 0x341b602b0 -[UIApplication _run]
19 UIKitCore 0x341b5f8ec UIApplicationMain
20 SwiftUI 0x34602e0f8 OUTLINED_FUNCTION_31
21 SwiftUI 0x34602df3c OUTLINED_FUNCTION_31
22 SwiftUI 0x345c9f864 OUTLINED_FUNCTION_26
23 MyApp 0x200d1f11c [inlined] AppLauncher.main (MyApp.swift:51)
24 MyApp 0x200d1f11c [inlined] AppLauncher.$main (<compiler-generated>:41)
25 MyApp 0x200d1f11c main
26 <unknown> 0x1d826edcc <redacted>
Example 2:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: SEGV_NOOP at 0x000047dab5b44360
Crashed Thread: 0
Application Specific Information:
Exception 1, Code 1, Subcode 79004676932448 >
KERN_INVALID_ADDRESS at 0x47dab5b44360.
Thread 0 Crashed:
0 libswiftCore.dylib 0x351b1611c _swift_release_dealloc
1 libswiftCore.dylib 0x351b0d4e0 [inlined] swift_dynamicCast
2 libswiftCore.dylib 0x351b0d4e0 swift_dynamicCast
3 MyApp 0x1073808d8 Store.currentState<T> (Store.swift:185)
4 MyApp 0x10737656c [inlined] Analytics.configuration.getter (Analytics.swift:17)
5 MyApp 0x10737656c IntervalBasedFlushPolicy.configure (IntervalBasedFlushPolicy.swift:42)
6 MyApp 0x10737e950 [inlined] thunk for closure
7 MyApp 0x10737e950 thunk for closure
8 MyApp 0x10738297c [inlined] thunk for closure
9 MyApp 0x10738297c thunk for closure
10 MyApp 0x107382a24 [inlined] Store.notify<T> (Store.swift:250)
11 MyApp 0x107382a24 Store.notify<T>
12 MyApp 0x107380d90 thunk for closure
13 libdispatch.dylib 0x36c7dc45c _dispatch_call_block_and_release
14 libdispatch.dylib 0x36c7ddf84 _dispatch_client_callout
15 libdispatch.dylib 0x36c7ec7f0 _dispatch_main_queue_drain
16 libdispatch.dylib 0x36c7ec440 _dispatch_main_queue_callback_4CF
17 CoreFoundation 0x35dc386c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
18 CoreFoundation 0x35dc1a028 __CFRunLoopRun
19 CoreFoundation 0x35dc1eeac CFRunLoopRunSpecific
20 GraphicsServices 0x3d2089364 GSEventRunModal
21 UIKitCore 0x3622e9664 -[UIApplication _run]
22 UIKitCore 0x3622e92c8 UIApplicationMain
23 SwiftUI 0x3650fe240 OUTLINED_FUNCTION_895
24 SwiftUI 0x36505f274 block_copy_helper.1
25 SwiftUI 0x365048628 OUTLINED_FUNCTION_901
26 MyApp 0x204cff11c [inlined] AppLauncher.main (MyApp.swift:51)
27 MyApp 0x204cff11c [inlined] AppLauncher.$main (<compiler-generated>:41)
28 MyApp 0x204cff11c main
29 <unknown> 0x1f55e0960 <redacted>
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (2 by maintainers)
amazing. @haugli @erichoracek’s fix is now available in
Analytics-Swift 1.5.4andSovran-Swift 1.1.1please feel free to follow up if you have any other issues or the crash persists. Thanks!Hi @alanjcharles @bsneed , I spent some time looking into this and it appears to be a thread safety issue with the Sovran-Swift library. I’ve put together a fix for it here https://github.com/segmentio/Sovran-Swift/pull/10
Hi @erichoracek thanks for letting us know- I’ll see what I can find. Talk soon!
Hi @haugli- thanks for your patience, we’re still looking into this. I’ll let you know as soon as we have more to share. In the meantime, please let me know if you get any additional information/insight on your end. Thanks, talk soon!