clion-cppcheck icon indicating copy to clipboard operation
clion-cppcheck copied to clipboard

Synchronous execution under ReadAction

Open firewave opened this issue 6 years ago • 11 comments

java.lang.Throwable: Synchronous execution under ReadAction: C:\Apps\cppcheck\cppcheck.exe -IC:/clion/mqtt/src/nodes --enable=all --suppress=noExplicitConstructor --suppress=unusedFunction --inline-suppr --language=c++ \"C:\Users\Username\AppData\Local\Temp\___endpoint.cpp\"
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:145)
	at com.intellij.execution.process.OSProcessHandler.checkEdtAndReadAction(OSProcessHandler.java:147)
	at com.intellij.execution.process.OSProcessHandler.waitFor(OSProcessHandler.java:85)
	at com.intellij.execution.process.CapturingProcessRunner.runProcess(CapturingProcessRunner.java:114)
	at com.intellij.execution.process.CapturingProcessRunner.runProcess(CapturingProcessRunner.java:73)
	at com.intellij.execution.process.CapturingProcessHandler.runProcessWithProgressIndicator(CapturingProcessHandler.java:83)
	at com.github.johnthagen.cppcheck.CppcheckInspection.executeCommandOnFile(CppcheckInspection.java:177)
	at com.github.johnthagen.cppcheck.CppcheckInspection.checkFile(CppcheckInspection.java:69)
	at com.intellij.codeInspection.LocalInspectionTool$1.visitFile(LocalInspectionTool.java:143)
	at com.jetbrains.cidr.lang.psi.impl.OCFileImpl.accept(OCFileImpl.java:448)
	at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:77)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$null$8(LocalInspectionsPass.java:323)
	at com.intellij.util.AstLoadingFilter.lambda$toComputable$2(AstLoadingFilter.java:167)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:125)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:114)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:109)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitRestElementsAndCleanup$9(LocalInspectionsPass.java:322)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:133)
	at com.intellij.concurrency.ApplierCompleter.tryToExecAllList(ApplierCompleter.java:231)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:159)
	at com.intellij.concurrency.ApplierCompleter.tryToExecAllList(ApplierCompleter.java:231)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:159)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:988)
	at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:105)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:592)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:538)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
	at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:116)
	at com.intellij.concurrency.ApplierCompleter.lambda$compute$0(ApplierCompleter.java:96)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:167)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:160)
	at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:96)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

Environment

  • Operating System: Windows 10
  • IDE Version: CLion 2019.3 EAP - happened with previous versions as well
  • Cppcheck plugin version: 1.2.0

Steps to reproduce the behaviour

I have no idea how to reproduce this, but it happens quite a bit while woring on a project.

firewave avatar Sep 19 '19 14:09 firewave

@fastasturtle, any thoughts?

johnthagen avatar Sep 19 '19 16:09 johnthagen

FYI This happens very frequently in one of my installations. In the other one I have never seen this at all. Both are running the same CLion, Cppcheck and plugin version.

firewave avatar Apr 02 '20 16:04 firewave

Looking at the plugin there is no special handling for isOnTheFly i.e. on the fly editor highlighting. Just grazing over the interface and some other plugins in the intellij-community repo you probably need to implement it using LocalInspectionTool.buildVisitor() instead.

firewave avatar Apr 06 '20 16:04 firewave

Just got a reply from a CLion developer about this:

The stack trace looks like it's an IntelliJ platform issue - I've seen it
somewhere else as well, will try to take a close look.

So it seems it is yet another upstream issue.

firewave avatar Nov 23 '20 10:11 firewave

I haven't come across this issue in quite a while but it only happened in a installation I am no longer using. So I am gonna keep this open for now.

firewave avatar Mar 14 '22 13:03 firewave

I am seeing this issue occur multiple times per day. Briefly, I see the stack trace above, and I am using:

  • macOS Ventura 13.3.1(a)
  • CLion 2023.1.2, (installation managed by JetBrains Toolbox)
  • cppcheck 2.10.3 (installed via "brew" into /usr/local/bin)
  • cppcheck plugin for CLion version 1.6.2

Let me know if there is additional information I can provide.

Sorry, but I am exclusively a C++ developer so you probably wouldn't want any PR I could give you ;-)

P.S. Let me know if there is an associated bug for JetBrains/CLion YouTrack if that is a more productive avenue to address this.

jmonschke-splunk avatar May 02 '23 20:05 jmonschke-splunk

Could you also please post your trace? Thanks.

firewave avatar May 02 '23 20:05 firewave

BTW: in searching on terms related to this I see that nx-console-idea-plugin also had a bug with a similar stack trace along with a fix. The Bug The Fix

Is this what you need, or is there another "trace" you need from CLion?

java.lang.Throwable: Synchronous execution under ReadAction: /usr/local/bin/cppcheck -I/Users/jmonschke/git/splunk1/main/src/search/dispatch/sscqueryinfo --enable=warning,performance,portability,style --language=c++ --xml /private/var/folders/w5/ncq8q__95h97tc3vwl1zt1d40000gn/T/DeEBpW1J_BucketTypes.cpp, see com.intellij.execution.process.OSProcessHandler#checkEdtAndReadAction() Javadoc for resolutions
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
	at com.intellij.execution.process.OSProcessHandler.checkEdtAndReadAction(OSProcessHandler.java:163)
	at com.intellij.execution.process.OSProcessHandler.waitFor(OSProcessHandler.java:94)
	at com.intellij.execution.process.CapturingProcessRunner.runProcess(CapturingProcessRunner.java:122)
	at com.intellij.execution.process.CapturingProcessRunner.runProcess(CapturingProcessRunner.java:81)
	at com.intellij.execution.process.CapturingProcessHandler.runProcessWithProgressIndicator(CapturingProcessHandler.java:72)
	at com.github.johnthagen.cppcheck.CppCheckInspectionImpl.executeCommandOnFile(CppCheckInspectionImpl.java:220)
	at com.github.johnthagen.cppcheck.CppcheckInspection.checkFile(CppcheckInspection.java:60)
	at com.intellij.codeInspection.LocalInspectionTool$1.visitFile(LocalInspectionTool.java:146)
	at com.jetbrains.cidr.lang.psi.impl.OCFileImpl.accept(OCFileImpl.java:428)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$10(InspectionRunner.java:323)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1102)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$11(InspectionRunner.java:331)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:229)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:187)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$12(InspectionRunner.java:337)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:159)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:151)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$13(InspectionRunner.java:300)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:130)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:119)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$14(InspectionRunner.java:300)
	at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.lambda$call$0(JobLauncherImpl.java:299)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.call(JobLauncherImpl.java:284)
	at com.intellij.concurrency.JobLauncherImpl.processQueue(JobLauncherImpl.java:352)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.processInOrder(InspectionRunner.java:299)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.visitElements(InspectionRunner.java:274)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$inspect$4(InspectionRunner.java:138)
	at com.intellij.codeInspection.InspectionEngine.withSession(InspectionEngine.java:227)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.inspect(InspectionRunner.java:114)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.collectInformationWithProgress(LocalInspectionsPass.java:115)
	at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:97)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:57)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:382)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1102)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:374)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:373)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:349)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:229)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:187)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:347)
	at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:181)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

jmonschke-splunk avatar May 02 '23 20:05 jmonschke-splunk

BTW: in searching on terms related to this I see that nx-console-idea-plugin also had a bug with a similar stack trace along with a fix.

Yeah, I was thinking that it might be "fixed" by simply making it asynchronous (actually pretty obvious as it complains about being "synchronous"). But that would "just" be getting of the error in our case and by the looks of it making the code more complex. The proper solution would probably be fixing #65. It is supposed to be "easy" but I am not going to look into that for quite a while (if ever).

Being able to debug the plugin might also help but I haven't been able to get that to work and I basically do "printf debugging". Make changes, build in IDEA, install in CLion, run it, check the notification, repeat, ... not very efficient. But without being able to reproduce it locally that would not be of much help.

It is quite baffling though that some installations have this error and some haven't. That isn't right and something is behaving differently upstream. Maybe some setting is different. I will take a look in a few days and see if I can figure something out.

firewave avatar May 02 '23 22:05 firewave

@firewave I'm not sure if this is useful or not, but I found this link lately that talks about the best patterns for running external linting tools in an IntelliJ extension

  • https://intellij-support.jetbrains.com/hc/en-us/community/posts/11275128092690-What-is-the-suggested-pattern-for-implementing-a-plugin-that-runs-an-external-command-that-generates-inspections-

See also

  • https://github.com/koxudaxi/ruff-pycharm-plugin/issues/148
  • https://github.com/koxudaxi/ruff-pycharm-plugin/pull/158

johnthagen avatar May 03 '23 11:05 johnthagen

Thanks for pointing that out. It's exactly what #65 is about. If you follow the link in it you see one of their developers suggesting exactly how to implement it. One even suggested to convert it for me. No idea why I didn't take him up on it. Well, pride, stupidity, mindfog, kittens, ... who knows?

But I want to get the 1.6 patch as well as 1.7.0 out first - still some work which needs to be done there. Afterward switch to Gradle to use that as the starting point for v2.

And if there will ever be generic SARIF support in JetBrains IDEs (and Cppcheck has added it) there won't be any more need for a dedicated plugin: https://youtrack.jetbrains.com/issue/IDEA-310400.

firewave avatar May 03 '23 13:05 firewave