Commit 7f2a58e
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: 2109040ba2a5fecf1fd5d41f541d15161af1bd8b1 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
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
0 commit comments