You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android: MetadataNode's shared class caches are not thread-safe across runtimes #100
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.
Activity