Android: MetadataNode's shared class caches are not thread-safe across runtimes
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- C++
- Sterne
- 27
- Forks
- 4
- Ø Merge
- 16 Std. 48 Min.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NativeScript/runtimes
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
NativeScript/runtimes#99 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 55/100
NativeScript/runtimes#98 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 53/100
NativeScript/runtimes#97 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
NativeScript/runtimes#94 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
NativeScript/runtimes#93 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in NativeScript/runtimes
Ähnliche Issues
-
bug priority: low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
chipsalliance/verible#2644 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
grafana/pyroscope-dotnet#470 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation P5 XS
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
open-astro/AlpacaBridge#1848 ·
Maintainer antworten meist innerhalb von 1 Tag
-
DiskANN AnnIterator returns unconverted IP distances after the graph walk runs out of candidatesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
zilliztech/knowhere#1933 ·
Maintainer antworten meist innerhalb von 1 Tag