Android jsi: console timers map is shared by every runtime thread without a lock
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 53/100
Piste de recherche
Read NativeScript/runtime/android/jsi/modules/console/Console.h and Console.cpp, tracing createConsole(), the console.time and console.timeEnd callbacks, and onDisposeRuntime(). Reproduce the race with the worker stress test described for #93, using HWASan if available. Done when creating and disposing runtimes during timer calls no longer races on the shared map; the issue lists a mutex or per-runtime state as possible approaches.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
On jsi, Console::s_rtToConsoleTimersMap (NativeScript/runtime/android/jsi/modules/console/Console.{h,cpp}) is a single, process-wide std::map that every runtime reads and writes from its own thread with no lock:
- insert:
createConsole()→s_rtToConsoleTimersMap.emplace(rt.identity(), ...), when each runtime starts; - find: the
console.time/console.timeEndcallbacks; - erase:
onDisposeRuntime(), when each runtime is disposed.
When workers start or stop while another runtime is using the map, one thread rebalances the tree while another walks it. That is a data race and can corrupt the heap or crash.
How it was found
The worker stress test used for #93 (12 workers at a time, created and terminated after 20–300 ms, with JS and Java GC forced throughout). HWASan was turned on locally; it is off by default. On jsi, this map crashed every stress run.
Expected
Creating or disposing one runtime can't corrupt another runtime's console timers. Possible fixes:
- guard the map with a mutex;
console.timeis not a hot path; - or make the timers per-runtime state owned by the
Consoleinstance or the runtime.
Environment
- Branch:
android-react-nativeat 64c7fed0 - Emulator: Android API 36, arm64, debug build of
platforms/android/test-appwith HWASan enabled locally - Binding layer: jsi
- Langage dominant
- C++
- Étoiles
- 27
- Forks
- 4
- Merge moyen
- 16 h 48 min
- PR mergées (30 j)
- 4
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NativeScript/runtimes
-
bug
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
NativeScript/runtimes#100 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
NativeScript/runtimes#99 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 4/5 1-2 jours Accessibilité débutants 55/100
NativeScript/runtimes#98 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
NativeScript/runtimes#94 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
NativeScript/runtimes#93 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de NativeScript/runtimes
Issues similaires
-
bug priority: low
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
chipsalliance/verible#2644 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
grafana/pyroscope-dotnet#470 ·
Les mainteneurs répondent en général sous 1 jour
-
documentation P5 XS
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
open-astro/AlpacaBridge#1848 ·
Les mainteneurs répondent en général sous 1 jour
-
DiskANN AnnIterator returns unconverted IP distances after the graph walk runs out of candidatesOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
zilliztech/knowhere#1933 ·
Les mainteneurs répondent en général sous 1 jour