Skip to content

[Android] HermesSamplingProfiler JNI "disable" method incorrectly mapped to ::enable #56120

Description

@elirangoshen

Description

In ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp, the registerNatives() function maps the JNI "disable" method to HermesSamplingProfiler::enable instead of
HermesSamplingProfiler::disable:

  void HermesSamplingProfiler::registerNatives() {
    javaClassLocal()->registerNatives({
        makeNativeMethod("enable", HermesSamplingProfiler::enable),
        makeNativeMethod("disable", HermesSamplingProfiler::enable),  // should be ::disable
        ...
    });
  }

This means calling HermesSamplingProfiler.disable() from Java actually calls enable() again, which can corrupt the sampling profiler state and lead to a SIGABRT crash (invalid pthread_t passed to pthread_kill in
the hermes-sampling thread).

The fix is a one-line change: HermesSamplingProfiler::enable → HermesSamplingProfiler::disable.

Steps to reproduce

This is a copy-paste bug visible by code inspection — no runtime reproduction steps needed.

React Native Version

0.81.4

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: macOS 26.3.1
  CPU: (12) arm64 Apple M3 Pro
  Memory: 113.33 MB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.5.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.5.1
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2025.08.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/eliran.goshen/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK:
    API Levels:
      - "30"
      - "31"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 30.0.3
      - 35.0.0
      - 36.0.0
    System Images:
      - android-24 | Google APIs ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-36 | Google APIs ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.3 AI-253.30387.90.2532.14935130
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.16
    path: /usr/bin/javac
  Ruby:
    version: 3.3.4
    path: /Users/eliran.goshen/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.1.0
    wanted: 20.1.0
  react:
    installed: 19.2.3
    wanted: 19.2.3
  react-native:
    installed: 0.84.1
    wanted: 0.84.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

crash_dump64  F  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  03-13 09:19:10.234 12345-12567 DEBUG   crash_dump64  F  Build fingerprint: 'google/oriole/oriole:14/AP2A.240305.019/11359284:userdebug/dev-keys'
  03-13 09:19:10.234 12345-12567 DEBUG   crash_dump64  F  Revision: 'MP1.0'
  03-13 09:19:10.234 12345-12567 DEBUG   crash_dump64  F  ABI: 'arm64'
  03-13 09:19:10.234 12345-12567 DEBUG   crash_dump64  F  Timestamp: 2026-03-13 09:19:10.123456789+0000
  03-13 09:19:10.234 12345-12567 DEBUG   crash_dump64  F  Process uptime: 45s
  03-13 09:19:10.235 12345-12567 DEBUG   crash_dump64  F  Cmdline: org.me.mobiexpensifyg.dev
  03-13 09:19:10.235 12345-12567 DEBUG   crash_dump64  F  pid: 12345, tid: 12567, name: hermes-sampling  >>> org.me.mobiexpensifyg.dev <<<
  03-13 09:19:10.235 12345-12567 DEBUG   crash_dump64  F  uid: 10245
  03-13 09:19:10.235 12345-12567 DEBUG   crash_dump64  F  signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
  03-13 09:19:10.235 12345-12567 DEBUG   crash_dump64  F  Abort message: 'invalid pthread_t passed to pthread_kill'
  03-13 09:19:10.236 12345-12567 DEBUG   crash_dump64  F      x0  0000000000000000  x1  0000000000003117  x2  0000000000000006  x3  0000000000000008
  03-13 09:19:10.236 12345-12567 DEBUG   crash_dump64  F      x4  0000000000000000  x5  0000000000000000  x6  0000000000000000  x7  0000000000000000
  03-13 09:19:10.236 12345-12567 DEBUG   crash_dump64  F      x8  00000000000000f0  x9  0000007a8b2c4580  x10 0000000000000001  x11 0000007a8b2c4580
  03-13 09:19:10.236 12345-12567 DEBUG   crash_dump64  F  backtrace:
  03-13 09:19:10.236 12345-12567 DEBUG   crash_dump64  F      #00 pc 00000000000536a0  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164)
  03-13 09:19:10.236 12345-12567 DEBUG   crash_dump64  F      #01 pc 0000000000053610  /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal+76)
  03-13 09:19:10.236 12345-12567 DEBUG   crash_dump64  F      #02 pc 0000000000088498  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_kill+208)
  03-13 09:19:10.237 12345-12567 DEBUG   crash_dump64  F      #03 pc 00000000001d910c  /data/app/~~K4yi4pfiSpqhU71Zw2QncA==/org.me.mobiexpensifyg.dev-Av-o2H_ytwlkY8sX3F9zZA==/lib/arm64/libhermes.so
  03-13 09:19:10.237 12345-12567 DEBUG   crash_dump64  F      #04 pc 00000000001da134  /data/app/~~K4yi4pfiSpqhU71Zw2QncA==/org.me.mobiexpensifyg.dev-Av-o2H_ytwlkY8sX3F9zZA==/lib/arm64/libhermes.so

MANDATORY Reproducer

https://github.com/elirangoshen/reproducer-hermes-crash-bug

Screenshots and Videos

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.Platform: AndroidAndroid applications.StaleThere has been a lack of activity on this issue and it may be closed soon.Type: Unsupported VersionIssues reported to a version of React Native that is no longer supported

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions