mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix JNI registration bug: HermesSamplingProfiler.disable() calls enable() (#56174)
Summary: `HermesSamplingProfiler::registerNatives()` maps the JNI `"disable"` method to `HermesSamplingProfiler::enable` instead of `HermesSamplingProfiler::disable` (copy-paste bug). This means calling `HermesSamplingProfiler.disable()` from Java actually calls `enable()` again, which corrupts the sampling thread state. This causes a SIGABRT crash on Android when any profiling tool (e.g. Sentry) calls `disable()` to stop profiling: ``` Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid (hermes-sampling) Abort message: 'invalid pthread_t passed to pthread_kill' ``` The fix is a one-character change: `::enable` → `::disable`. Related issue: https://github.com/facebook/react-native/issues/56120 ## Changelog: [ANDROID] [FIXED] - Fix HermesSamplingProfiler.disable() JNI registration calling enable() instead of disable() Pull Request resolved: https://github.com/facebook/react-native/pull/56174 Test Plan: This is a copy-paste bug fix visible by code inspection. The correct `disable()` C++ implementation already exists (line 20-24, calls `hermesAPI->disableSamplingProfiler()`) — it was just never invoked due to the incorrect JNI registration. Verified in production at Expensify: with this fix applied via patch-package, the SIGABRT crash no longer occurs when Sentry Hermes profiling is enabled. Reviewed By: javache Differential Revision: D97489621 Pulled By: cortinico fbshipit-source-id: 2109040ba2a5fecf1fd5d41f541d15161af1bd8b
This commit is contained in:
1 parent
af11b9365e
commit
7f2a58e46c
1 file changed
+1
-1
+1
-1
@@ -34,7 +34,7 @@ void HermesSamplingProfiler::dumpSampledTraceToFile(
|
||||
void HermesSamplingProfiler::registerNatives() {
|
||||
javaClassLocal()->registerNatives({
|
||||
makeNativeMethod("enable", HermesSamplingProfiler::enable),
|
||||
makeNativeMethod("disable", HermesSamplingProfiler::enable),
|
||||
makeNativeMethod("disable", HermesSamplingProfiler::disable),
|
||||
makeNativeMethod(
|
||||
"dumpSampledTraceToFile",
|
||||
HermesSamplingProfiler::dumpSampledTraceToFile),
|
||||
|
||||
Reference in new issue
Block a user