[Android] HermesSamplingProfiler JNI "disable" method incorrectly mapped to ::enable
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.3k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Mở ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp và kiểm tra registerNatives(). Xác minh rằng entry JNI "disable" được ánh xạ tới HermesSamplingProfiler::disable thay vì ::enable. Hoàn tất nghĩa là mapping một dòng đã được sửa và lệnh gọi disable không còn gọi enable nữa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, cpp
- Lĩnh vực
- mobile-dev
- Loại issue
- Lỗi
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 92/100