Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in unrelated file: Read access is allowed from inside read-action only #708

Closed
jansorg opened this issue Dec 17, 2024 · 7 comments · Fixed by #714
Closed

Exception in unrelated file: Read access is allowed from inside read-action only #708

jansorg opened this issue Dec 17, 2024 · 7 comments · Fixed by #714
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jansorg
Copy link

jansorg commented Dec 17, 2024

I have plugin SumnekoLua installed, which uses LSP4IJ 0.9.0.
Navigating in a Kotlin file causes this error, even though there's no LSP server running or even associated with *.kt or any other Kotlin file.

I'm not sure why LSP4IJ is activated in this case. Would it be possible to skip this when there's no server at all?

An errorReporter build into the LSP4IJ plugin would help to report issues like this more automatically.

Thanks!

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); If you access or modify model on EDT consider wrapping your code in WriteIntentReadAction  or ReadAction; see https://jb.gg/ij-platform-threading for details
Current thread: Thread[#144,ApplicationImpl pooled thread 3,4,main] 1748729779 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[#92,AWT-EventQueue-0,6,main] 336048610
	at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:218)
	at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:155)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:921)
	at com.intellij.psi.impl.source.tree.TreeElement.assertReadAccessAllowed(TreeElement.java:437)
	at com.intellij.psi.impl.source.tree.SharedImplUtil.getParent(SharedImplUtil.java:31)
	at com.intellij.psi.impl.source.tree.LeafPsiElement.getParent(LeafPsiElement.java:56)
	at com.intellij.psi.impl.smartPointers.Identikit$ByType.findParent(Identikit.java:101)
	at com.intellij.psi.impl.smartPointers.Identikit$ByType.findInside(Identikit.java:83)
	at com.intellij.psi.impl.smartPointers.Identikit$ByType.findPsiElement(Identikit.java:73)
	at com.intellij.psi.impl.compiled.ClsElementImpl.getMirror(ClsElementImpl.java:134)
	at com.intellij.psi.impl.compiled.ClsElementImpl.getTextOffset(ClsElementImpl.java:169)
	at com.redhat.devtools.lsp4ij.usages.LSPUsageSearcher.processElementUsages(LSPUsageSearcher.java:101)
	at com.intellij.find.findUsages.FindUsagesManager.lambda$createUsageSearcher$10(FindUsagesManager.java:407)
	at com.intellij.find.findUsages.FindUsagesManager$1.run(FindUsagesManager.java:317)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:491)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:133)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$7(CoreProgressManager.java:542)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:249)
	at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:223)
	at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:45)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:222)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$14(CoreProgressManager.java:674)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:749)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:705)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:673)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:203)
	at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:249)
	at com.intellij.openapi.progress.impl.ProgressRunner$ProgressRunnable.run(ProgressRunner.java:502)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$18(ProgressRunner.java:467)
	at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
	at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
	at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:107)
	at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:101)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$19(ProgressRunner.java:463)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
	at java.base/java.lang.Thread.run(Thread.java:1583)

@fbricon fbricon added the bug Something isn't working label Dec 17, 2024
@angelozerr
Copy link
Contributor

So bad -(

@SCWells72 we need to do a fix.

@angelozerr
Copy link
Contributor

An errorReporter build into the LSP4IJ plugin would help to report issues like this more automatically.

Is there any chance that you could provide a PR for that?

@jansorg
Copy link
Author

jansorg commented Dec 17, 2024

@angelozerr I'm sorry, but I currently don't have the capacity to do that.

@angelozerr
Copy link
Contributor

angelozerr commented Dec 17, 2024

No problem. I have discussed about that with @fbricon and we fear that it will polluate github repo with a lot of issues.

I am very busy for now with Quarkus support and DAP support that I am doing in my free time (to have the capability to debug typescript, swift, etc) so it is not in my priority.

@SCWells72
Copy link
Contributor

@jansorg, I've started a PR for a prospective fix that wraps the offending code in a read action. I say "prospective" because unfortunately I'm unable to reproduce the actual error locally having tried both 2023.2 and 2024.3 versions of IntelliJ IDEA Community Edition. Can you provide a specific environment in which you're able to reproduce the problem so I can try to reproduce it again locally in a matching environment and confirm the fix?

@angelozerr
Copy link
Contributor

It should be fixed with #712

@jansorg once https://github.com/redhat-developer/lsp4ij/actions/runs/12380125102 will be finished (in 2 minutes), please install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds and give us feedback if it fixes your issue.

Thanks.

@angelozerr angelozerr assigned SCWells72 and ScrewTSW and unassigned ScrewTSW Dec 17, 2024
@angelozerr angelozerr added this to the 0.10.0 milestone Dec 17, 2024
@jansorg
Copy link
Author

jansorg commented Dec 18, 2024

@angelozerr Unfortunately, I'm still seeing this (or another?) exception with the latest nightly (0.9.1-20241217-193530).

This happens frequently whenever I press ctrl+b (Navigate > Declarations or Usages). There was running LSP server.

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); If you access or modify model on EDT consider wrapping your code in WriteIntentReadAction  or ReadAction; see https://jb.gg/ij-platform-threading for details
Current thread: Thread[#408,ApplicationImpl pooled thread 11,4,main] 1964319025 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[#94,AWT-EventQueue-0,6,main] 1258336388
	at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:218)
	at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:155)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:921)
	at com.intellij.psi.impl.source.tree.TreeElement.assertReadAccessAllowed(TreeElement.java:437)
	at com.intellij.psi.impl.source.tree.SharedImplUtil.findFileElement(SharedImplUtil.java:78)
	at com.intellij.psi.impl.source.tree.SharedImplUtil.getContainingFile(SharedImplUtil.java:53)
	at com.intellij.psi.impl.source.tree.CompositePsiElement.getContainingFile(CompositePsiElement.java:89)
	at com.redhat.devtools.lsp4ij.usages.LSPUsageSearcher.processElementUsages(LSPUsageSearcher.java:59)
	at com.intellij.find.findUsages.FindUsagesManager.lambda$createUsageSearcher$10(FindUsagesManager.java:407)
	at com.intellij.find.findUsages.FindUsagesManager$1.run(FindUsagesManager.java:317)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:491)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:133)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$7(CoreProgressManager.java:542)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:249)
	at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:223)
	at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:45)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:222)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$14(CoreProgressManager.java:674)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:749)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:705)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:673)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:203)
	at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:249)
	at com.intellij.openapi.progress.impl.ProgressRunner$ProgressRunnable.run(ProgressRunner.java:502)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$18(ProgressRunner.java:467)
	at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
	at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
	at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:107)
	at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:101)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$19(ProgressRunner.java:463)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
	at java.base/java.lang.Thread.run(Thread.java:1583)

@angelozerr angelozerr reopened this Dec 18, 2024
angelozerr added a commit to angelozerr/lsp4ij that referenced this issue Dec 18, 2024
angelozerr added a commit to angelozerr/lsp4ij that referenced this issue Dec 18, 2024
angelozerr added a commit to angelozerr/lsp4ij that referenced this issue Dec 18, 2024
@angelozerr angelozerr self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants