getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.58k stars 337 forks source link

Crash: EXC_BAD_ACCESS +[RNSentryEventEmitter emitModuleTableUpdate:] #228

Closed aiham closed 7 years ago

aiham commented 7 years ago

OS:

Platform:

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

v8.4.0
5.3.0
ScrollCare@1.1.5 /Users/aiham/dev/scrollcare-client
├── babel-plugin-transform-remove-console@6.8.5
├── immutable@3.8.1
├── lodash@4.17.4
├── prop-types@15.5.10
├── react@16.0.0-alpha.12
├── react-native@0.48.1
├── react-native-camera@0.10.0 (git+https://github.com/lwansbrough/react-native-camera.git#537b7696b491f5f1a2ce70cfb8477b8e5b80a7ed)
├── react-native-ci-tools@1.1.0 (git+https://github.com/aiham/react-native-ci-tools.git#309f62a1824bcdaad6fa03825cddcec6c3db8297)
├── react-native-country-picker-modal@0.3.0
├── react-native-datepicker@1.6.0
├── react-native-device-info@0.11.0
├── react-native-elements@0.15.0
├── react-native-fetch-blob@0.10.8
├── react-native-google-analytics-bridge@5.3.0
├── react-native-modal-datetime-picker@4.11.0
├── react-native-modal-dropdown@0.4.4
├── react-native-path@0.0.5
├── react-native-photo-view@1.5.0 (git+https://github.com/alwx/react-native-photo-view.git#22877b2a9df47d23cfe068a2f4d2709daaf6d1f5)
├── react-native-popup-menu@0.8.1
├── react-native-selectme@1.2.3
├── react-native-sentry@0.23.0
├── react-native-simple-onboarding@0.1.1
├── react-native-simple-radio-button@2.6.1
├── react-native-sleek-loading-indicator@0.1.3
├── react-native-thumbnail-grid@0.2.0 (git+https://github.com/aiham/react-native-photo-grid.git#39f928f2ce7730f7c55690277b4e4e0fbe1bf724)
├── react-native-timeline-listview@0.2.2
├── react-native-vector-icons@4.3.0
├── react-native-version@2.3.1
├── react-navigation@1.0.0-beta.12
├── react-redux@5.0.6
├── redux@3.7.2
├── redux-batched-actions@0.1.6
├── redux-persist@4.9.1
├── redux-persist-transform-immutable@4.3.0
├── redux-thunk@2.2.0
└── uuid@3.1.0

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:

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:

EXC_BAD_ACCESS
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:

aiham commented 7 years ago

I can confirm disabling Sentry prevents the app from crashing.

HazAT commented 7 years ago

Hey, I will look into this.

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

HazAT commented 7 years ago

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

aiham commented 7 years ago

@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:

EXC_BAD_ACCESS
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
ScrollCare@1.1.5 /Users/aiham/dev/scrollcare-client
├── babel-plugin-transform-remove-console@6.8.5
├── immutable@3.8.1
├── lodash@4.17.4
├── prop-types@15.5.10
├── react@16.0.0-alpha.12
├── react-native@0.48.1
├── react-native-camera@0.10.0 (git+https://github.com/lwansbrough/react-native-camera.git#dc1724507a8fb6a66ef53442704c2d0340ef40b1)
├── react-native-ci-tools@1.1.0 (git+https://github.com/aiham/react-native-ci-tools.git#309f62a1824bcdaad6fa03825cddcec6c3db8297)
├── react-native-country-picker-modal@0.3.0
├── react-native-datepicker@1.6.0
├── react-native-device-info@0.11.0
├── react-native-elements@0.15.0
├── react-native-fetch-blob@0.10.8
├── react-native-google-analytics-bridge@5.3.0
├── react-native-modal-datetime-picker@4.11.0
├── react-native-modal-dropdown@0.4.4
├── react-native-path@0.0.5
├── react-native-photo-view@1.5.0 (git+https://github.com/alwx/react-native-photo-view.git#22877b2a9df47d23cfe068a2f4d2709daaf6d1f5)
├── react-native-popup-menu@0.8.1
├── react-native-selectme@1.2.3
├── react-native-sentry@0.23.1
├── react-native-simple-onboarding@0.1.1
├── react-native-simple-radio-button@2.6.1
├── react-native-sleek-loading-indicator@0.1.3
├── react-native-thumbnail-grid@0.2.0 (git+https://github.com/aiham/react-native-photo-grid.git#39f928f2ce7730f7c55690277b4e4e0fbe1bf724)
├── react-native-timeline-listview@0.2.2
├── react-native-vector-icons@4.3.0
├── react-native-version@2.3.1
├── react-navigation@1.0.0-beta.12
├── react-redux@5.0.6
├── redux@3.7.2
├── redux-batched-actions@0.1.6
├── redux-persist@4.9.1
├── redux-persist-transform-immutable@4.3.0
├── redux-thunk@2.2.0
└── uuid@3.1.0

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

HazAT commented 7 years ago

@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

aiham commented 7 years ago

@HazAT

{
    67 = RCTGoogleAnalyticsBridge;
    69 = RNSentry;
}

image

aiham commented 7 years ago

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

HazAT commented 7 years ago

@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 ...

aiham commented 7 years ago

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

HazAT commented 7 years ago

@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 ...

aiham commented 7 years ago

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

image

HazAT commented 7 years ago

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

[RNSentryEventEmitter emitModuleTableUpdate:_self.moduleMapping.mutableCopy];
aiham commented 7 years ago

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

HazAT commented 7 years ago

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

aiham commented 7 years ago

@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.

HazAT commented 7 years ago

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

aiham commented 7 years ago

@HazAT Thanks! 🎉

fungilation commented 7 years ago

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!

jer-sen commented 5 years ago

I still face this issue with react-native-sentry@0.42.0 and react-native@0.59.0 during the next reload after a JS or native crash :


EXC_BAD_ACCESS
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 react-native-code-push@5.5.2 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.

yevhenlv commented 4 years ago

I still face this issue with react-native-sentry@0.42.0 and react-native@0.59.0 during the next reload after a JS or native crash :


EXC_BAD_ACCESS
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 react-native-code-push@5.5.2 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)