[Android] HermesSamplingProfiler JNI "disable" method incorrectly mapped to ::enable
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 92/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- android, cpp
- 领域
- mobile-dev
调研方向
打开 ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp 并检查 registerNatives()。确认 JNI 的 "disable" 条目映射到 HermesSamplingProfiler::disable,而不是 ::enable。完成的标准是修正这一行映射,并且 disable 调用不再调用 enable。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react/react-native 的其他 Issue
-
Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 82/100
react/react-native#58565 · 1 条评论 · 2 个 reaction ·
-
Needs: Author Feedback Needs: Repro
难度 2/5 1-3 小时 新手友好度 88/100
react/react-native#58555 · 4 条评论 · 1 个 reaction ·
-
Needs: Attention Needs: Repro
难度 2/5 1-3 小时 新手友好度 85/100
react/react-native#58526 · 2 条评论 ·
-
Needs: Author Feedback Needs: Repro
难度 2/5 1-3 小时 新手友好度 85/100
react/react-native#58448 · 1 条评论 ·
-
Needs: Attention Needs: Repro
难度 2/5 半天 新手友好度 82/100
react/react-native#58441 · 2 条评论 ·
查看 react/react-native 的全部 Issue
相似的 Issue
-
Website Doc Typo 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 1/5 1-3 小时 新手友好度 92/100
autowarefoundation/autoware_universe#13413 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
automated-analysis bug memory-safety
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 88/100