Android Sample Application New Architecture Crash with RN 0.75 when profiling is enabled
What React Native libraries do you use?
RN New Architecture, Hermes
Are you using sentry.io or on-premise?
sentry.io (SaS)
@sentry/react-native SDK Version
6.0.0
How does your development environment look like?
info Fetching system and libraries information...
System: OS: macOS 14.6.1 CPU: (10) arm64 Apple M1 Pro Memory: 257.28 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.20.4 path: ~/.nvm/versions/node/v18.20.4/bin/node Yarn: version: 3.6.4 path: ~/.nvm/versions/node/v18.20.4/bin/yarn npm: version: 10.7.0 path: ~/.nvm/versions/node/v18.20.4/bin/npm Watchman: version: 2024.09.09.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/antonis/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 24.0 - iOS 18.0 - macOS 15.0 - tvOS 18.0 - visionOS 2.0 - watchOS 11.0 Android SDK: Not Found IDEs: Android Studio: 2024.1 AI-241.18034.62.2411.12169540 Xcode: version: 16.0/16A242d path: /usr/bin/xcodebuild Languages: Java: version: 17.0.8 path: /opt/homebrew/opt/openjdk@17/bin/javac Ruby: version: 3.3.0 path: /Users/antonis/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.3.1 wanted: 18.3.1 react-native: installed: 0.75.4 wanted: 0.75.4 react-native-macos: Not Found npmGlobalPackages: "react-native": Not Found Android: hermesEnabled: true newArchEnabled: true iOS: hermesEnabled: Not found newArchEnabled: false
Sentry.init()
See https://github.com/getsentry/sentry-react-native/blob/6.0.0/samples/react-native/src/App.tsx#L47
Steps to Reproduce
- Run the Sentry sample app on Android
- Observe the app crashing after a few interactions (emulator) or immediately (on an actual device).
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xf9ffffffffffd0 in tid 28855 (pool-2-thread-1), pid 28724 (ctnative.sample)
Cmdline: io.sentry.reactnative.sample
pid: 28724, tid: 28855, name: pool-2-thread-1 >>> io.sentry.reactnative.sample <<<
#00 pc 00000000001cf690 /data/app/~~L28pDt3h9E04FIXseGByHQ==/io.sentry.reactnative.sample-7ncgwSgsy4tLasRHD0YOSw==/base.apk!libhermes.so (offset 0x1918000) (BuildId: db078b0afc73e2129f8850376d84ff09ee5dcf01)
#01 pc 00000000001d4168 /data/app/~~L28pDt3h9E04FIXseGByHQ==/io.sentry.reactnative.sample-7ncgwSgsy4tLasRHD0YOSw==/base.apk!libhermes.so (offset 0x1918000) (BuildId: db078b0afc73e2129f8850376d84ff09ee5dcf01)
#02 pc 00000000001d3b0c /data/app/~~L28pDt3h9E04FIXseGByHQ==/io.sentry.reactnative.sample-7ncgwSgsy4tLasRHD0YOSw==/base.apk!libhermes.so (offset 0x1918000) (BuildId: db078b0afc73e2129f8850376d84ff09ee5dcf01)
Package [io.sentry.reactnative.sample] reported as REPLACED, but missing application info. Assuming REMOVED.
- Disable profiling by commenting out the
profilesSampleRate - Run the app and verify that there is no crash.
Expected Result
No crash with profiling enabled
Actual Result
The app crashes when profiling is enabled.
Notes
- The issue was introduced with the sample apps upgrade to
0.75.4https://github.com/getsentry/sentry-react-native/pull/4155 - A reanimate bug which had a similar stack trace was investigated but upgrading to the latest version (or removing the library) didn't solve the issue.
Noting that I wasn't able to reproduce the crash with a basic RN 0.75.4 RN app with profiling enabled.
Project setup
npx @react-native-community/cli init AwesomeProject --version 0.75.4
cd AwesomeProject
npx @sentry/wizard@latest -i reactNative
Set newArchEnabled=true in android/gradle.properties
Sentry initialisation
Sentry.init({
...
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
});
Adding the ndk-stack of the investigated crash:
(offset 0x42b8000) (BuildId: db078b0afc73e2129f8850376d84ff09ee5dcf01)
hermes::vm::HermesValue::getTag() const
/__w/react-native/react-native/packages/react-native/sdks/hermes/include/hermes/VM/HermesValue.h:224:27
hermes::vm::HermesValue::isObject() const
/__w/react-native/react-native/packages/react-native/sdks/hermes/include/hermes/VM/HermesValue.h:408:12
hermes::vm::StackFramePtrT
The above would indicate that the error occurs in profiler sampling of the latest Hermes. Changing the Sentry profiler sampling we notice that:
- disabling the platform profilers didn't make a difference
- Reducing the sample rate (e.g.
profilesSampleRate: 0.1) seems to hide the issue