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

Android: MetadataNode's shared class caches are not thread-safe across runtimes

Abierto
#100 0 comentarios 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
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
android, cpp
Área
backend, mobile

Línea de trabajo

Read NativeScript/ffi/jni/napi/metadata/MetadataNode.{h,cpp} and NativeScript/ffi/jni/jsi/metadata/MetadataNode.{h,cpp}. Trace the listed find-or-create paths and check how their raw pointers are retained across runtimes. Done means all three shared caches are safe for concurrent access and concurrent misses return one stable node per class.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Summary

MetadataNode's name caches are process-wide and shared by every runtime, but no lock guards them. Each runtime's thread can find and insert into them:

  • s_name2TreeNodeCache (std::string → MetadataTreeNode*): GetOrCreateTreeNodeByName;
  • s_name2NodeCache (std::string → MetadataNode*): GetOrCreate, GetOrCreateInternal, and class extension (fullExtendedName);
  • s_treeNode2NodeCache (MetadataTreeNode* → MetadataNode*): GetOrCreateInternal.

They are in both binding layers: NativeScript/ffi/jni/{napi,jsi}/metadata/MetadataNode.{h,cpp}, all three robin_hood::unordered_map.

The main runtime and every worker resolve Java classes through these caches. The first time two runtimes touch a class that isn't cached yet, both insert concurrently. One can rehash the table while the other is reading it, and a find / emplace pair can also leave two MetadataNodes for the same class.

Why this is separate from the other statics

These caches aren't keyed by runtime. They are meant to be shared, and they hand out raw pointers that callers keep. So a per-runtime map or a plain ConcurrentMap swap won't do. A fix has to keep returned pointers stable and make "find, else create and insert" atomic, so that two threads never create two nodes for one class. For example:

  • one mutex around each find-or-create path;
  • or a shared reader lock with an exclusive lock on the miss path.

Environment

  • Branch: android-react-native at 64c7fed0
  • Found by reading the code while fixing #93; not seen crashing on its own.

Related: #93, #96.

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.