react-native: EXC_CORPSE_NOTIFY iOS crash when using native modules

The app intermittently crashes when resolving or rejecting a promise in a native module. Possibly related to https://github.com/facebook/react-native/issues/5011.

This reproduces with several native modules so I don’t think it’s related to a specific module.

Environment

Environment:
  OS: macOS High Sierra 10.13.3
  Node: 9.5.0
  Yarn: 1.3.2
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: ^16.3.0-alpha.1 => 16.3.0-alpha.3
  react-native: 0.55.0 => 0.55.0

Steps to Reproduce

  1. Create a simple Native Module
  2. Use it

Expected Behavior

I expect the data to flow back and forth as documented.

Actual Behavior

The app intermittently crashes with what looks like a memory issue.

From my observation I think it happens when resolving or rejecting a promise from Objective-C.

Here’s a screenshot from the crash organizer. Note that the crash occurred on thread 10, not the main thread:

image

So it looks like it’s somewhere in this code:

https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/React/CxxModule/RCTNativeModule.mm#L86-L115

I see that code can throw this exception:

Exception ‘%@’ was thrown while invoking %s on target %@ with params %@\ncallstack: %@", exception

But I don’t see that error anywhere in the crash log so I’m not sure where to find it. I’m not sure if this was the actual exception, since the crash report says EXC_CORPSE_NOTIFY so it may be a red herring

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 28 (8 by maintainers)

Most upvoted comments

Think this issue should be re-opened as there seems to be more people getting this issue, including myself?

We’re having the same issue in React Native 59.9 It only crashes on iOS. It only crashes in production. It doesn’t always crash. It crashes without doing anything (just starting the app and waiting on a static screen). It crashes after 3-10 seconds We don’t download heavy amounts of data. It has the exact same com.facebook.react.ExceptionsManagerQueue stacktrace. In the complete logfile there is only one line of code coming from us and it’s in com.apple.main-thread: right before UIKitCore and GraphicsServices, so it’s very likely not coming from our code.

We do connect to quite a few native-modules: From react-native:

  • Core
  • CxxBridge
  • RCTPushNotification
  • DevSupport
  • RCTText
  • RCTImage
  • RCTNetwork
  • RCTWebSocket
  • RCTSettings
  • RCTAnimation
  • RCTLinkingIOS
  • RCTAnimation
  • RCTActionSheet
  • RCTGeolocation
  • RCTImage
  • RCTVibration
  • yoga
  • DoubleConversion
  • glog
  • Folly

From third party:

  • RSKImageCropper
  • QBImagePickerController
  • iOSDFULibrary
  • react-native-ble-plx-swift
  • RCTSystemSetting
  • react-native-netinfo
  • react-native-ble-plx
  • react-native-blur
  • RNI18n
  • BVLinearGradient
  • react-native-sensitive-info
  • RNVectorIcons
  • rn-fetch-blob
  • RNImageCropPicker
  • RNCAsyncStorage
  • react-native-orientation
  • react-native-video/VideoCaching

Edit:

  • This has happened on all 4 iOS devices at our office consistently, whether the app was clean installed for the first time or already on there for a longer time
  • Once the crashing stops (on some devices after the 1st time, others still have it after 50 times), it seems like it’s over for good and the app works fine (tried about 50 times now).
  • The only thing that changes in the last 2 months, is that we renewed our Distribution, Developer, Apple Push Notification and APNs Development iOS certificates. Afterwards edited the provisioning profiles of the app to use the new certificates and revoked the old ones. According to apple, this does not affect downloaded apps from the app store and installing a new app has no issues. (https://developer.apple.com/support/certificates/)

Never ever have I experienced something like this, nor do I have any clue what could be the cause.

OS Version:          iPhone OS 12.3.1 (16F203)
Baseband Version:    3.03.04
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  2

Application Specific Information:
abort() called

Last Exception Backtrace:
0   CoreFoundation                 0x20f1e927c __exceptionPreprocess + 228
1   libobjc.A.dylib               0x20e3c39f8 objc_exception_throw + 55
2   React                         0x104e816c4 0x104e50000 + 202436
3   React                         0x104eae13c 0x104e50000 + 385340
4   CoreFoundation                 0x20f1f0900 __invoking___ + 143
5   CoreFoundation                 0x20f0d24d0 -[NSInvocation invoke] + 291
6   CoreFoundation                 0x20f0d3104 -[NSInvocation invokeWithTarget:] + 59
7   React                         0x104ed1b84 0x104e50000 + 531332
8   React                         0x104ed8670 0x104e50000 + 558704
9   React                         0x104ed83d0 0x104e50000 + 558032
10  libdispatch.dylib             0x20ec28a38 _dispatch_call_block_and_release + 23
11  libdispatch.dylib             0x20ec297d4 _dispatch_client_callout + 15
12  libdispatch.dylib             0x20ebd2320 _dispatch_lane_serial_drain$VARIANT$mp + 591
13  libdispatch.dylib             0x20ebd2e3c _dispatch_lane_invoke$VARIANT$mp + 427
14  libdispatch.dylib             0x20ebdb4a8 _dispatch_workloop_worker_thread + 595
15  libsystem_pthread.dylib       0x20ee09114 _pthread_wqthread + 303
16  libsystem_pthread.dylib       0x20ee0bcd4 start_wqthread + 3


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib         0x000000020ed7b0f4 mach_msg_trap + 8
1   libsystem_kernel.dylib         0x000000020ed7a5a0 mach_msg + 72
2   CoreFoundation                 0x000000020f17aa10 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                 0x000000020f175920 __CFRunLoopRun + 1360
4   CoreFoundation                 0x000000020f1750b0 CFRunLoopRunSpecific + 436
5   GraphicsServices               0x000000021137579c GSEventRunModal + 104
6   UIKitCore                     0x000000023baef978 UIApplicationMain + 212
7   minze                         0x0000000104bea8a0 0x104be4000 + 26784
8   libdyld.dylib                 0x000000020ec3a8e0 start + 4

Thread 1:
0   libsystem_pthread.dylib       0x000000020ee0bcd0 start_wqthread + 0

Thread 2 name:  Dispatch queue: com.facebook.react.ExceptionsManagerQueue
Thread 2 Crashed:
0   libsystem_kernel.dylib         0x000000020ed860dc __pthread_kill + 8
1   libsystem_pthread.dylib       0x000000020edff094 pthread_kill$VARIANT$mp + 380
2   libsystem_c.dylib             0x000000020ecdfea8 abort + 140
3   libc++abi.dylib               0x000000020e3ac788 __cxa_bad_cast + 0
4   libc++abi.dylib               0x000000020e3ac934 default_unexpected_handler+ 6452 () + 0
5   libobjc.A.dylib               0x000000020e3c3e00 _objc_terminate+ 24064 () + 124
6   libc++abi.dylib               0x000000020e3b8838 std::__terminate(void (*)+ 55352 ()) + 16
7   libc++abi.dylib               0x000000020e3b88c4 std::terminate+ 55492 () + 84
8   libdispatch.dylib             0x000000020ec297e8 _dispatch_client_callout + 36
9   libdispatch.dylib             0x000000020ebd2320 _dispatch_lane_serial_drain$VARIANT$mp + 592
10  libdispatch.dylib             0x000000020ebd2e3c _dispatch_lane_invoke$VARIANT$mp + 428
11  libdispatch.dylib             0x000000020ebdb4a8 _dispatch_workloop_worker_thread + 596
12  libsystem_pthread.dylib       0x000000020ee09114 _pthread_wqthread + 304
13  libsystem_pthread.dylib       0x000000020ee0bcd4 start_wqthread + 4

Thread 3 name:  com.apple.uikit.eventfetch-thread
Thread 3:
0   libsystem_kernel.dylib         0x000000020ed7b0f4 mach_msg_trap + 8
1   libsystem_kernel.dylib         0x000000020ed7a5a0 mach_msg + 72
2   CoreFoundation                 0x000000020f17aa10 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                 0x000000020f175920 __CFRunLoopRun + 1360
4   CoreFoundation                 0x000000020f1750b0 CFRunLoopRunSpecific + 436
5   Foundation                     0x000000020fb42fac -[NSRunLoop+ 32684 (NSRunLoop) runMode:beforeDate:] + 300
6   Foundation                     0x000000020fb42e3c -[NSRunLoop+ 32316 (NSRunLoop) runUntilDate:] + 96
7   UIKitCore                     0x000000023bbd5494 -[UIEventFetcher threadMain] + 136
8   Foundation                     0x000000020fc6f6a4 __NSThread__start__ + 984
9   libsystem_pthread.dylib       0x000000020ee082c0 _pthread_body + 128
10  libsystem_pthread.dylib       0x000000020ee08220 _pthread_start + 44
11  libsystem_pthread.dylib       0x000000020ee0bcdc thread_start + 4

Thread 4 name:  com.facebook.react.JavaScript
Thread 4:
0   libsystem_kernel.dylib         0x000000020ed7b0f4 mach_msg_trap + 8
1   libsystem_kernel.dylib         0x000000020ed7a5a0 mach_msg + 72
2   CoreFoundation                 0x000000020f17aa10 __CFRunLoopServiceMachPort + 236
3   CoreFoundation                 0x000000020f175920 __CFRunLoopRun + 1360
4   CoreFoundation                 0x000000020f1750b0 CFRunLoopRunSpecific + 436
5   React                         0x0000000104e9e8fc 0x104e50000 + 321788
6   Foundation                     0x000000020fc6f6a4 __NSThread__start__ + 984
7   libsystem_pthread.dylib       0x000000020ee082c0 _pthread_body + 128
8   libsystem_pthread.dylib       0x000000020ee08220 _pthread_start + 44
9   libsystem_pthread.dylib       0x000000020ee0bcdc thread_start + 4

Thread 5 name:  JavaScriptCore bmalloc scavenger
Thread 5:
0   libsystem_kernel.dylib         0x000000020ed85ee4 __psynch_cvwait + 8
1   libsystem_pthread.dylib       0x000000020ee00cf8 _pthread_cond_wait$VARIANT$mp + 636
2   libc++.1.dylib                 0x000000020e35d128 std::__1::condition_variable::__do_timed_wait+ 33064 (std::__1::unique_lock<std::__1::mutex>&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) + 96
3   JavaScriptCore                 0x0000000216385fcc std::__1::cv_status std::__1::condition_variable::wait_until<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >+ 589772 (std::__1::unique_lock<std::__1::mutex>&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > const&) + 124
4   JavaScriptCore                 0x0000000216385e7c std::__1::cv_status std::__1::condition_variable_any::wait_until<std::__1::unique_lock<bmalloc::Mutex>, std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >+ 589436 (std::__1::unique_lock<bmalloc::Mutex>&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > const&) + 116
5   JavaScriptCore                 0x0000000216384b14 bmalloc::Scavenger::threadRunLoop+ 584468 () + 296
6   JavaScriptCore                 0x0000000216384214 bmalloc::Scavenger::Scavenger+ 582164 (std::__1::lock_guard<bmalloc::Mutex>&) + 0
7   JavaScriptCore                 0x0000000216385c54 std::__1::__thread_specific_ptr<std::__1::__thread_struct>::set_pointer+ 588884 (std::__1::__thread_struct*) + 0
8   libsystem_pthread.dylib       0x000000020ee082c0 _pthread_body + 128
9   libsystem_pthread.dylib       0x000000020ee08220 _pthread_start + 44
10  libsystem_pthread.dylib       0x000000020ee0bcdc thread_start + 4

Thread 6:
0   libsystem_pthread.dylib       0x000000020ee0bcd0 start_wqthread + 0

Thread 7 name:  JSC Heap Collector Thread
Thread 7:
0   libsystem_kernel.dylib         0x000000020ed85ee4 __psynch_cvwait + 8
1   libsystem_pthread.dylib       0x000000020ee00cf8 _pthread_cond_wait$VARIANT$mp + 636
2   JavaScriptCore                 0x0000000216347594 WTF::ThreadCondition::timedWait+ 333204 (WTF::Mutex&, WTF::WallTime) + 144
3   JavaScriptCore                 0x000000021632e1dc WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void + 229852 ()> const&, WTF::TimeWithDynamicClockType const&) + 2004
4   JavaScriptCore                 0x0000000216302020 bool WTF::Condition::waitUntil<WTF::Lock>+ 49184 (WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 184
5   JavaScriptCore                 0x00000002163023b0 WTF::Function<void ()>::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0>::call+ 50096 () + 216
6   JavaScriptCore                 0x00000002163457f8 WTF::Thread::entryPoint+ 325624 (WTF::Thread::NewThreadContext*) + 260
7   JavaScriptCore                 0x0000000216346d04 WTF::wtfThreadEntryPoint+ 331012 (void*) + 12
8   libsystem_pthread.dylib       0x000000020ee082c0 _pthread_body + 128
9   libsystem_pthread.dylib       0x000000020ee08220 _pthread_start + 44
10  libsystem_pthread.dylib       0x000000020ee0bcdc thread_start + 4

Thread 8:
0   libsystem_pthread.dylib       0x000000020ee0bcd0 start_wqthread + 0

Thread 9:
0   libsystem_pthread.dylib       0x000000020ee0bcd0 start_wqthread + 0

Thread 10:
0   libsystem_pthread.dylib       0x000000020ee0bcd0 start_wqthread + 0

Thread 11:
0   libsystem_pthread.dylib       0x000000020ee0bcd0 start_wqthread + 0

Thread 12 name:  Heap Helper Thread
Thread 12:
0   libsystem_kernel.dylib         0x000000020ed85ee4 __psynch_cvwait + 8
1   libsystem_pthread.dylib       0x000000020ee00cf8 _pthread_cond_wait$VARIANT$mp + 636
2   JavaScriptCore                 0x0000000216347594 WTF::ThreadCondition::timedWait+ 333204 (WTF::Mutex&, WTF::WallTime) + 144
3   JavaScriptCore                 0x000000021632e1dc WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void + 229852 ()> const&, WTF::TimeWithDynamicClockType const&) + 2004
4   JavaScriptCore                 0x0000000216302020 bool WTF::Condition::waitUntil<WTF::Lock>+ 49184 (WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 184
5   JavaScriptCore                 0x00000002163023b0 WTF::Function<void ()>::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0>::call+ 50096 () + 216
6   JavaScriptCore                 0x00000002163457f8 WTF::Thread::entryPoint+ 325624 (WTF::Thread::NewThreadContext*) + 260
7   JavaScriptCore                 0x0000000216346d04 WTF::wtfThreadEntryPoint+ 331012 (void*) + 12
8   libsystem_pthread.dylib       0x000000020ee082c0 _pthread_body + 128
9   libsystem_pthread.dylib       0x000000020ee08220 _pthread_start + 44
10  libsystem_pthread.dylib       0x000000020ee0bcdc thread_start + 4

Thread 2 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x000000028335d9b7
    x4: 0x000000020e3bbb71   x5: 0x000000016b3ba460   x6: 0x000000000000006e   x7: 0xffffffffffffffec
    x8: 0x0000000000000c00   x9: 0x000000020ee03888  x10: 0x000000020edfef18  x11: 0x0000000000000003
   x12: 0x0000000000000000  x13: 0x0000000000000001  x14: 0x0000000000000010  x15: 0x000000000000000d
   x16: 0x0000000000000148  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x000000016b3bb000  x21: 0x000000016b3ba460  x22: 0x0000000000002803  x23: 0x000000016b3bb0e0
   x24: 0x000000028085b340  x25: 0x0000000000000000  x26: 0x000000028085b340  x27: 0x0000000000000000
   x28: 0x000000016b3bb0e0   fp: 0x000000016b3ba3c0   lr: 0x000000020edff094
    sp: 0x000000016b3ba390   pc: 0x000000020ed860dc cpsr: 0x00000000

@MrKriegler Thanks mate. I have added Firebase Crashlytics today and found that the problem is due to react-native-gesture-handler. I was just looking for the solution and saw your comment.

is there any solution for this issue? facing same issue in review process in appstore. with real devices and emulators everything working perfectly. but when it put as new production release they are rejecting build and crash reports same as this report.

@solixmedia We rewrote the app in Swift and got rid of React Native.

seems like we are seeing this:

OS Version:          iPhone OS 11.2 (15C114)
Baseband Version:    6.30.04
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  21

Application Specific Information:
abort() called

Filtered syslog:
None found
Thread 21 name:  Dispatch queue: com.facebook.react.ExceptionsManagerQueue
Thread 21 Crashed:
0   libsystem_kernel.dylib        	0x00000001824282e8 __pthread_kill + 8
1   libsystem_pthread.dylib       	0x000000018253d2f8 pthread_kill$VARIANT$mp + 396
2   libsystem_c.dylib             	0x0000000182396fbc abort + 140
3   libc++abi.dylib               	0x0000000181b33068 __cxa_bad_cast + 0
4   libc++abi.dylib               	0x0000000181b33210 default_unexpected_handler+ 8720 () + 0
5   libobjc.A.dylib               	0x0000000181b5c810 _objc_terminate+ 34832 () + 124
6   OURApp Beta                  	0x000000010124e6ec 0x1011f0000 + 386796
7   libc++abi.dylib               	0x0000000181b4b54c std::__terminate(void (*)+ 107852 ()) + 16
8   libc++abi.dylib               	0x0000000181b4aea8 __cxxabiv1::exception_cleanup_func+ 106152 (_Unwind_Reason_Code, _Unwind_Exception*) + 0
9   libobjc.A.dylib               	0x0000000181b5c65c _objc_exception_destructor+ 34396 (void*) + 0
10  OURApp Beta                  	0x00000001012d9560 0x1011f0000 + 955744
11  OURApp Beta                  	0x00000001012d90a8 0x1011f0000 + 954536
12  libdispatch.dylib             	0x0000000182292a54 _dispatch_call_block_and_release + 24
13  libdispatch.dylib             	0x0000000182292a14 _dispatch_client_callout + 16
14  libdispatch.dylib             	0x000000018229c96c _dispatch_queue_serial_drain$VARIANT$mp + 528
15  libdispatch.dylib             	0x000000018229d2fc _dispatch_queue_invoke$VARIANT$mp + 340
16  libdispatch.dylib             	0x000000018229dd20 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 404
17  libdispatch.dylib             	0x00000001822a603c _dispatch_workloop_worker_thread$VARIANT$mp + 644
18  libsystem_pthread.dylib       	0x000000018253af1c _pthread_wqthread + 932
19  libsystem_pthread.dylib       	0x000000018253ab6c start_wqthread + 4

I was just able to reproduce what I think is the same issue in the simulator by pressing <kbd>⌘R</kbd> a few times:

image

Interestingly, the stack trace is identical, but this says EXC_BAD_ACCESS vs. EXC_CORPSE_NOTIFY. I wonder if the difference is because the former is a debug build but the latter is a release build.

I tried to inspect some of the variables in lldb, but then Xcode crashed 🙄