Skip to content

Commit 7f2a58e

Browse files
elirangoshenmeta-codesync[bot]
authored andcommitted
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: #56120 ## Changelog: [ANDROID] [FIXED] - Fix HermesSamplingProfiler.disable() JNI registration calling enable() instead of disable() Pull Request resolved: #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
1 parent af11b93 commit 7f2a58e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/react-native/ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void HermesSamplingProfiler::dumpSampledTraceToFile(
3434
void HermesSamplingProfiler::registerNatives() {
3535
javaClassLocal()->registerNatives({
3636
makeNativeMethod("enable", HermesSamplingProfiler::enable),
37-
makeNativeMethod("disable", HermesSamplingProfiler::enable),
37+
makeNativeMethod("disable", HermesSamplingProfiler::disable),
3838
makeNativeMethod(
3939
"dumpSampledTraceToFile",
4040
HermesSamplingProfiler::dumpSampledTraceToFile),

0 commit comments

Comments
 (0)