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

Offen Anfängerfreundlich
#56,120 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Anfängerfreundlichkeit
92/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
android, cpp
Bereich
mobile-dev

Rechercherichtung

Öffne ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp und überprüfe registerNatives(). Verifiziere, dass der JNI-"disable"-Eintrag HermesSamplingProfiler::disable statt ::enable zugeordnet ist. Erledigt ist die Aufgabe, wenn die Zuordnung in einer Zeile korrigiert ist und der disable-Aufruf nicht mehr enable aufruft.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Needs: Attention Needs: Repro Platform: Android Stale Type: Unsupported Version
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

Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus react/react-native

Alle Issues in react/react-native

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.