Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#100 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

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
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
android, cpp
Bereich
backend, mobile

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

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.

Vorherrschende Sprache
C++
Sterne
27
Forks
4
Ø Merge
16 Std. 48 Min.
Gemergte PRs (30 T.)
4

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus NativeScript/runtimes

Alle Issues in NativeScript/runtimes

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.