Sentry-react-native: Crash: EXC_BAD_ACCESS +[RNSentryEventEmitter emitModuleTableUpdate:]

Created on 10 Sep 2017  ·  20Comments  ·  Source: getsentry/sentry-react-native

OS:

  • [ ] Windows
  • [X] MacOS
  • [ ] Linux

_Platform:_

  • [X] iOS
  • [ ] Android

Output of node -v && npm -v && npm ls --prod --depth=0

v8.4.0
5.3.0
[email protected] /Users/aiham/dev/scrollcare-client
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] (git+https://github.com/lwansbrough/react-native-camera.git#537b7696b491f5f1a2ce70cfb8477b8e5b80a7ed)
├── [email protected] (git+https://github.com/aiham/react-native-ci-tools.git#309f62a1824bcdaad6fa03825cddcec6c3db8297)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] (git+https://github.com/alwx/react-native-photo-view.git#22877b2a9df47d23cfe068a2f4d2709daaf6d1f5)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] (git+https://github.com/aiham/react-native-photo-grid.git#39f928f2ce7730f7c55690277b4e4e0fbe1bf724)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Config:

import { Sentry } from 'react-native-sentry';
Sentry.config(sentryDSN).install();

I have following issue:

React native app crashes randomly while using iOS Simulator (haven't tried a real device) and it originates at [RNSentryEventEmitter emitModuleTableUpdate:]. Not sure how to troubleshoot this.

Steps to reproduce:

  • Use the app for a while using iOS Simulator.

I don't have specific repro steps but this always happens eventually, no matter what screens I navigate to or what actions I make. Sometimes it happens immediately, sometimes it takes a while. I've reproduced it 16 times here: https://sentry.io/ham-byte/scrollcaredev/?query=is%3Aunresolved+emitModuleTableUpdate

Actual result:

  • Crashes with:
Attempted to dereference garbage pointer 0x10e6b202d.
Originated at or in a subcall of +[RNSentryEventEmitter emitModuleTableUpdate:]
mach exception
EXC_BAD_ACCESS
signal
SIGBUS (10)
ScrollCare
0x10e792cde
+[RNSentryEventEmitter emitModuleTableUpdate:]
Called from:
ScrollCare
__36-[RNSentry swizzleInvokeWithBridge:]_block_invoke_2
ScrollCare
0x10e59f4a0
facebook::react::RCTNativeModule::invokeInner(unsigned int, folly::dynamic const&&)
ScrollCare
0x10e59f07c
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
ScrollCare
0x10e59f039
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
Called from:
libdispatch
_dispatch_call_block_and_release

Expected result:

  • No crash

Most helpful comment

I still face this issue with [email protected] and [email protected] during the next reload after a JS or native crash :

class > isKindOfClass: > moduleMapping >
Attempted to dereference garbage pointer 0x4c7cbe613190.

+[RNSentryEventEmitter emitModuleTableUpdate:] /.../node_modules/react-native-sentry/ios/RNSentryEventEmitter.m:54
__36-[RNSentry swizzleInvokeWithBridge:]_block_invoke_2 /.../node_modules/react-native-sentry/ios/RNSentry.m

I have [email protected] installed. Error occurs at least with a new native version (without any CodePush OTA update installed).

Setting deactivateStacktraceMerging: true seems to be a good workaround.

All 20 comments

I can confirm disabling Sentry prevents the app from crashing.

Hey, I will look into this.

In the mean time you can pass
deactivateStacktraceMerging: true
as an option to prevent the crash from happening.

Hey, I've released 0.23.1 which fixes this issue.

@HazAT Thanks for that but it's still crashing, even after deleting node_modules, ios and android folders and the npm lock file.

deactivateStacktraceMerging: true does prevent the crashing.

Here's the latest one:

Attempted to dereference garbage pointer 0x108f0b000.
Originated at or in a subcall of +[RNSentryEventEmitter emitModuleTableUpdate:]

mach exception: EXC_BAD_ACCESS
signal: SIGBUS (10)

ScrollCare
0x10fb10c8a
+[RNSentryEventEmitter emitModuleTableUpdate:]
Called from:
ScrollCare
__36-[RNSentry swizzleInvokeWithBridge:]_block_invoke_2
ScrollCare
0x10f91d410
facebook::react::RCTNativeModule::invokeInner(unsigned int, folly::dynamic const&&)
ScrollCare
0x10f91cfec
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
ScrollCare
0x10f91cfa9
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
Called from:
libdispatch
_dispatch_call_block_and_release
$ node -v && npm -v && npm ls --prod --depth=0
v8.4.0
5.3.0
[email protected] /Users/aiham/dev/scrollcare-client
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] (git+https://github.com/lwansbrough/react-native-camera.git#dc1724507a8fb6a66ef53442704c2d0340ef40b1)
├── [email protected] (git+https://github.com/aiham/react-native-ci-tools.git#309f62a1824bcdaad6fa03825cddcec6c3db8297)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] (git+https://github.com/alwx/react-native-photo-view.git#22877b2a9df47d23cfe068a2f4d2709daaf6d1f5)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] (git+https://github.com/aiham/react-native-photo-grid.git#39f928f2ce7730f7c55690277b4e4e0fbe1bf724)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

And I'm using iOS Simulator for iPhone 6 (iOS 10.3) with React Native DEBUG configuration.

@aiham, I am not able to reproduce the crash.
Can you add a exception breakpoint in Xcode
https://stackoverflow.com/questions/17802662/exception-breakpoint-in-xcode
and post the value of moduleTable when it crashes in + (void)emitModuleTableUpdate:(NSDictionary *)moduleTable

@HazAT

{
    67 = RCTGoogleAnalyticsBridge;
    69 = RNSentry;
}

image

Is it because RCTGoogleAnalyticsBridge is a mutable string? Just a guess.

@aiham Thx for helping out, I've tried a few combinations and I am really puzzled why it crashes (it's not because of mutable string)
Still looking into it ...

@HazAT Let me know if there's anything else I can try.

@aiham
Can you try adding mutableCopy so the call looks like this:

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:moduleTable.mutableCopy
                                                       options:0
                                                         error:&error];

I am mostly guessing though ...

@HazAT It now failed at the isValidJSONObject call without reaching mutableCopy. moduleTable looked the same as before.

image

@aiham Can you modify the file RNSentry.m should be line 256
and change the call to

[RNSentryEventEmitter emitModuleTableUpdate:_self.moduleMapping.mutableCopy];

@HazAT I can't get it to crash anymore with that change.

@aiham Is it because of the change in RNSentry.m or it magically stopped crashing?

@HazAT I'm pretty sure it's the change. After the change I used the app for a few minutes without crashing, when I undid the change it crashed very quickly after.

Ok, @aiham thank you for helping me out. I will release a fix for that in a few minutes 0.23.2.
👍

@HazAT Thanks! 🎉

I confirm I've seen this many times on iOS simulator only. Didn't attribute it to Sentry being the cause as it was somewhat random and goes away.

Thanks for the report and fix!

I still face this issue with [email protected] and [email protected] during the next reload after a JS or native crash :

class > isKindOfClass: > moduleMapping >
Attempted to dereference garbage pointer 0x4c7cbe613190.

+[RNSentryEventEmitter emitModuleTableUpdate:] /.../node_modules/react-native-sentry/ios/RNSentryEventEmitter.m:54
__36-[RNSentry swizzleInvokeWithBridge:]_block_invoke_2 /.../node_modules/react-native-sentry/ios/RNSentry.m

I have [email protected] installed. Error occurs at least with a new native version (without any CodePush OTA update installed).

Setting deactivateStacktraceMerging: true seems to be a good workaround.

I still face this issue with [email protected] and [email protected] during the next reload after a JS or native crash :

class > isKindOfClass: > moduleMapping >
Attempted to dereference garbage pointer 0x4c7cbe613190.

+[RNSentryEventEmitter emitModuleTableUpdate:] /.../node_modules/react-native-sentry/ios/RNSentryEventEmitter.m:54
__36-[RNSentry swizzleInvokeWithBridge:]_block_invoke_2 /.../node_modules/react-native-sentry/ios/RNSentry.m

I have [email protected] installed. Error occurs at least with a new native version (without any CodePush OTA update installed).

Setting deactivateStacktraceMerging: true seems to be a good workaround.

this option by default is true (if you didn't set it false in your init function as config)

Was this page helpful?
0 / 5 - 0 ratings