Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#97 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

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
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
android, cpp
Domaine
backend

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

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
Langage dominant
C++
Étoiles
27
Forks
4
Merge moyen
16 h 48 min
PR mergées (30 j)
4

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de NativeScript/runtimes

Toutes les issues de NativeScript/runtimes

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.