mixpanel / mixpanel-swift

Official iOS (Swift) Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
432 stars 236 forks source link

Cause: Crash due to signal: SIGSEGV(SEGV_MAPERR) at 00000000 #463

Closed bytetang closed 2 years ago

bytetang commented 3 years ago

found some users still face the the crash when mixpanel archiveToFile. I saw a race condition bug has been resolved in 2.9.1, but we used the sdk version is v2.9.3.

after doing the detail investigation in a user , we found it's cup was overload. I guess this might effect the the archive performance or cause the crash.

if we provide the wrong type of event or properties data to Mixpanel track API. it's might effect most of users. but now it's a small probability event.

any suggestion?

Mixpanel swift SDK version: v2.9.3 OS: 14.6 Swift version: 5.4 Crash thread stack:

Thread 30 [Crashed]:

0    CoreFoundation                           0x197032960     _CFArrayReplaceValues + 836
1    CoreFoundation                           0x197031ea0     CFArrayAppendValue + 155
2    CoreFoundation                           0x19703e794     _flattenPlist + 271
3    CoreFoundation                           0x19703e938     _flattenPlist + 691
4    CoreFoundation                           0x19703e8d0     _flattenPlist + 587
5    CoreFoundation                           0x19703e938     _flattenPlist + 691
6    CoreFoundation                           0x19703e8d0     _flattenPlist + 587
7    CoreFoundation                           0x19703e328     _CFBinaryPlistWriteOrPresize + 231
8    Foundation                               0x198301f44     -[NSKeyedArchiver finishEncoding] + 543
9    Foundation                               0x1983030dc     -[NSKeyedArchiver encodedData] + 71
10   Foundation                               0x1983025c0     +[NSKeyedArchiver archivedDataWithRootObject:requiringSecureCoding:error:] + 119
11   Mixpanel                                 0x10bc250b4     $specialized static Persistence.archiveToFile(_:object:token:) (Persistence.swift:164)
12   Mixpanel                                 0x10bc21d78     closure #1 in static Persistence.archiveEvents(_:token:) + 83
13   Mixpanel                                 0x10bbe6134     thunk for @callee_guaranteed () -> () (<compiler-generated>:0)
14   Mixpanel                                 0x10bbe6154     thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>:0)
15   libdispatch.dylib                        0x196d53298     _dispatch_client_callout + 15
16   libdispatch.dylib                        0x196d35f70     _dispatch_lane_barrier_sync_invoke_and_complete + 55
17   Mixpanel                                 0x10bc3ca3c     closure #4 in closure #1 in People.addPeopleRecordToQueueWithAction(_:properties:) (People.swift:96)
18   Mixpanel                                 0x10bc639f0     closure #1 in ReadWriteLock.read(closure:) (ReadWriteLock.swift:19)
19   Mixpanel                                 0x10bbe6134     thunk for @callee_guaranteed () -> () (<compiler-generated>:0)
20   Mixpanel                                 0x10bbe6154     thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>:0)
21   libdispatch.dylib                        0x196d53298     _dispatch_client_callout + 15
22   libdispatch.dylib                        0x196d3654c     _dispatch_sync_invoke_and_complete + 55
23   Mixpanel                                 0x10bc3c6dc     closure #1 in People.addPeopleRecordToQueueWithAction(_:properties:) (People.swift:95)
24   Mixpanel                                 0x10bbe6154     thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>:0)
25   libdispatch.dylib                        0x196d522b0     _dispatch_call_block_and_release + 23
26   libdispatch.dylib                        0x196d53298     _dispatch_client_callout + 15
27   libdispatch.dylib                        0x196d2f344     _dispatch_lane_serial_drain$VARIANT$armv81 + 567
28   libdispatch.dylib                        0x196d2fe2c     _dispatch_lane_invoke$VARIANT$armv81 + 399
29   libdispatch.dylib                        0x196d3966c     _dispatch_workloop_worker_thread + 691
30   libsystem_pthread.dylib                  0x1df4d95bc     _pthread_wqthread + 271
31   libsystem_pthread.dylib                  0x1df4dc86c     $start_wqthread + 7
zihejia commented 3 years ago

hi @bytetang , thanks for bringing it up. We are considering refactoring the archiving part of the SDK which will greatly improve the performance and reduce crashes. We will update you on this.

cflorion commented 3 years ago

Hi, thanks. I am kind of concerned about this, we have these crashes in our app in production. Is this something you consider as a priority ? Thanks :)

RamblinWreck77 commented 3 years ago

@zihejia Is this related? We see some crashes at startup:

Screen Shot 2021-07-05 at 11 04 31 AM
jaredmixpanel commented 3 years ago

@bytetang @cflorion @RamblinWreck77 We have a new beta release that addresses this issue if you'd like to try it out here: https://github.com/mixpanel/mixpanel-swift/releases/tag/v3.0.0.beta.4 (Please do note the beta version does not include Messages & Experiments functionality)

jaredmixpanel commented 3 years ago

Instructions for installing the beta branch are here: https://github.com/mixpanel/mixpanel-swift/tree/3.0.0.beta#installation

RamblinWreck77 commented 3 years ago

@jaredmixpanel Awesome! We'll try this out and let you know how it works! We don't use the messages/experiments functionality anyways

cflorion commented 3 years ago

@jaredmixpanel Great!! Thanks, we will try it out

RamblinWreck77 commented 3 years ago

@jaredmixpanel So I have some good news to report. We shipped an update with just this mixpanel lib change and:

1) It's out to 70% of users so far

2) No new crashes/slight reduction in crash rate

3) Our % of sessions that experienced 100% CPU for >1 dropped from 13% 0.03%.

Screen Shot 2021-09-13 at 10 05 37 AM

4) No event anomalies have been detected by our product team in any of their reports so far.

Holy cow, nice work team!

zihejia commented 2 years ago

Marking it closed now. Since 3.0.0 release is just around the corner(Jan 1, 2022) and we are encouraging everyone to try it out. We are fully supporting it!

Reminder: On Jan 1, 2022, Messages & Experiments will be removed from Mixapnel.