launchdarkly / ios-client-sdk

LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
https://docs.launchdarkly.com/sdk/client-side/ios
Other
70 stars 85 forks source link

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000020 #131

Closed jamztang closed 6 years ago

jamztang commented 6 years ago

Hi guys, I was tracking down a crash, and seems like it's related to DarklyEventSource.

Crashed: com.apple.root.user-initiated-qos
0  JavaScriptCore                 0x7fffa3cfbe2a JSC::HeapTimer::timerDidFire(__CFRunLoopTimer*, void*) + 26
1  CoreFoundation                 0x7fffa1855c54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
2  CoreFoundation                 0x7fffa18558df __CFRunLoopDoTimer + 1071
3  CoreFoundation                 0x7fffa185543a __CFRunLoopDoTimers + 298
4  CoreFoundation                 0x7fffa184cb81 __CFRunLoopRun + 2065
5  CoreFoundation                 0x7fffa184c114 CFRunLoopRunSpecific + 420
6  CoreFoundation                 0x7fffa188bb91 CFRunLoopRun + 97
7  DarklyEventSource              0x1060694bc -[LDEventSource _open] (LDEventSource.m:296)
8  libdispatch.dylib              0x7fffb6fa48fc _dispatch_client_callout + 8
9  libdispatch.dylib              0x7fffb6fb9a16 _dispatch_continuation_pop + 533
10 libdispatch.dylib              0x7fffb6fafa6c _dispatch_source_latch_and_call + 194
11 libdispatch.dylib              0x7fffb6fa713b _dispatch_source_invoke + 1248
12 libdispatch.dylib              0x7fffb6fa66b5 _dispatch_root_queue_drain + 476
13 libdispatch.dylib              0x7fffb6fa648c _dispatch_worker_thread3 + 99
14 libsystem_pthread.dylib        0x7fffb71f35a2 _pthread_wqthread + 1299
15 libsystem_pthread.dylib        0x7fffb71f307d start_wqthread + 13

I went further to look at our Podfile.lock, we're referencing to LaunchDarkly 2.10.1 and DarklyEventSource 3.2.0

The closest thing I can find is this: https://github.com/launchdarkly/ios-eventsource/blob/3.2.0/LDEventSource/LDEventSource.m#L293-L295

CFRunLoopRun();

Are there any known reports that CFRunLoopRun will crash is certain situation?

markpokornycos commented 6 years ago

@jamztang Thank you for providing the stack trace. I'm looking into this. Are you able to reproduce this consistently? If so, can you provide steps to reproduce it?

jamztang commented 6 years ago

Actually we're not 100% sure how to reproduce this, but this happens to be 2 of our most happening crashes

screen shot 2018-04-12 at 4 40 25 pm

One info is that our app is a OSX menu bar application, it could go active and resignActive pretty quickly. If I add logs to AppDelegate and LDEventSource I see something like this.

AppDelegate.willBecomeActive
LDEventSource._open
AppDelegate.willResignActive
LDEventSource.close
LDEventSource.receiveResponse // Sometimes it doesn't but sometimes it shows.

We're trying to disable streaming for now and see how it goes.

markpokornycos commented 6 years ago

Knowing that this is a macOS app is helpful. Also knowing that the app goes to the background quickly is helpful. The LDEventSource delays making the connection to the clientstream for 1 second. If the app moves to the background before that time, then the SDK should dealloc the LDEventSource. I will experiment with our sample macOS app to see if I can duplicate the crash there.

After studying these for some time, I have a couple of more questions. Do you use JavaScript in your app? Or maybe a JS based library? If so, do you setup any timers, or set a handler on a timer provided to you by a third party?

I appreciate any more information you can give us.

markpokornycos commented 6 years ago

LDEventSource crash

arun251 commented 6 years ago

Hi @jamztang , We believe this issue is fixed in iOS SDK 2.12.