镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(psi): make LuaDeclarationTreeStub position map thread-safe - #626

Open
KSkun wants to merge 1 commit into
EmmyLua:masterfrom
KSkun:fix/declaration-tree-stub-concurrent-map
Open

KSkun wants to merge 1 commit into
EmmyLua:masterfrom
KSkun:fix/declaration-tree-stub-concurrent-map

Conversation

@KSkun

@KSkun KSkun commented Oct 10, 2026

Copy link
Copy Markdown

LuaDeclarationTreeStub.getPosition mutates a plain LinkedHashMap (getOrPut), and stub trees can be built and used by several inspection threads at once (LuaDeclarationTree.get is check-then-set, and scopes are cached on shared PSI). A concurrent put/resize corrupts the map; the surviving thread then loops inside a read action and blocks the write lock until the IDE is killed.

Seen twice in Rider 2026.2.3.1 / EmmyLua 1.4.26. Both freezes had one busy thread, in HashMap$TreeNode.split (HashMap.java:2304), reached from RemoveUnusedLocal -> LuaIndexReference.resolve -> TyClass.findMemberType ->
LuaDeclarationTree.get -> buildTree -> getPosition. The UI thread was waiting for a write-intent permit.

Fix: ConcurrentHashMap.computeIfAbsent + AtomicInteger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant