react / react/react-native

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

Ouverte Adaptée aux débutants
#56,120 6 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Needs: Attention Needs: Repro Platform: Android Stale Type: Unsupported Version
Langage dominant
C++
Étoiles
127k
Forks
25.3k
Merge moyen
1 j 23 h
PR mergées (30 j)
4

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Ouvrez ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp et examinez registerNatives(). Vérifiez que l’entrée JNI "disable" est associée à HermesSamplingProfiler::disable plutôt qu’à ::enable. C’est terminé lorsque l’association sur une ligne est corrigée et que l’appel à disable n’invoque plus enable.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
android, cpp
Domaine
mobile-dev
Type d'issue
Bug
Difficulté
1/5
Temps estimé
Moins d'une heure
Activité
Active
Clarté
Clairement spécifiée
Accessibilité débutants
92/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.