Android: MetadataNode's shared class caches are not thread-safe across runtimes
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
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
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-nativeat 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
- 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 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 53/100
NativeScript/runtimes#97 · 1 comentario ·
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
-
launch-client --save-creds creates creds/<account>/ with mode 755, not 700Posiblemente ocupada @metis-sprock la tomó hoy. Abiertobacklog bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
EchoTools/nevr-runtime#1471 ·
Los mantenedores suelen responder en 1 día
-
.NET ep:WebGPU platform:web
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/onnxruntime#33755 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
grumpycoders/pcsx-redux#2530 ·
-
A-tools P-medium S-ready-to-start studio task
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Status: Needs confirmation Status: Needs triage Type: Code Quality
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día