Android jsi: console timers map is shared by every runtime thread without a lock
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 53/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- C++
- Estrellas
- 27
- Forks
- 4
- Merge medio
- 16 h 48 min
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NativeScript/runtimes
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
NativeScript/runtimes#100 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
NativeScript/runtimes#99 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 1-2 días Aptitud para principiantes 55/100
NativeScript/runtimes#98 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
NativeScript/runtimes#94 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
NativeScript/runtimes#93 ·
Los mantenedores suelen responder en 1 día
Todos los issues de NativeScript/runtimes
Issues similares
-
bug-unconfirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Extended search mode does not find escape sequences (\t, \n, \r...)Posiblemente ocupada @CyrilB1531 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
dail8859/NotepadNext#1181 ·
Los mantenedores suelen responder en 1 día
-
A-tools P-low S-blocked task
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
☢️ Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenAtomFoundation/pikiwidb#3309 ·
-
audit(c2): add_project_arguments('/experimental:c11atomics', language: ['c', 'cpp']) for MS (C2-13)Abiertohygiene type:refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día