Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Android jsi: console timers map is shared by every runtime thread without a lock

Abierto
#97 1 comentario 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
android, cpp
Área
backend

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

bug

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.timeEnd callbacks;
  • 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.time is not a hot path;
  • or make the timers per-runtime state owned by the Console instance or the runtime.

Environment

  • Branch: android-react-native at 64c7fed0
  • Emulator: Android API 36, arm64, debug build of platforms/android/test-app with 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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NativeScript/runtimes

Todos los issues de NativeScript/runtimes

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.