zero9178 / C-Cpp-Coverage-for-CLion

Get coverage data in CLion using gcov or llvm-cov
MIT License
38 stars 2 forks source link

Exception in CLion #22

Closed claremacrae closed 3 years ago

claremacrae commented 3 years ago

I've been getting some errors from CLion that say they are in this plugin.

I'm running 2020.2... But the exceptions say:

Exception in plugin CC++ Coverage (2020.3.0 EAP).

java.lang.AssertionError: 98; this: 10
    at com.intellij.openapi.editor.impl.IntervalTreeImpl.checkBelongsToTheTree(IntervalTreeImpl.java:928)
    at com.intellij.openapi.editor.impl.IntervalTreeImpl.removeInterval(IntervalTreeImpl.java:960)
    at com.intellij.openapi.editor.impl.MarkupModelImpl.removeHighlighter(MarkupModelImpl.java:228)
    at net.zero9178.cov.editor.CoverageHighlighter$$special$$inlined$invokeLater$1.run(actions.kt:61)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:216)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:24)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:199)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:324)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:85)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:134)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:190)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:976)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:843)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:454)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:773)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:453)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:501)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

I got 7 over the last 10 minutes or so... they all differ only in the first lines, which are:

java.lang.AssertionError: 98; this: 10
java.lang.AssertionError: 101; this: 20
java.lang.AssertionError: 104; this: 30
java.lang.AssertionError: 107; this: 46
java.lang.AssertionError: 110; this: 62
java.lang.AssertionError: 113; this: 72
java.lang.AssertionError: 116; this: 82
zero9178 commented 3 years ago

I have just pushed a commit that should fix this issues. I used the chance to rethink some of the assumptions I made in the code. I attached the current zip file in case you want to immediately try it it out. Make sure to uninstall the current version of the plugin and then in the plugins menu click on the gear next to Installed and then Install Plugin from disk and simply select the zip file.

I'll likely upload the changes to Jetbrains plugin repository and release a version tomorrow morning (in 24 hours). After that it usually takes a maximum of 2 business days for Jetbrains to approve it and push the plugin update. C C++ Coverage-2020.3.1.zip

claremacrae commented 3 years ago

Wow - thanks Markus (I assume, from your email address on your account here...)

I've set up the new version, I'll let you know how it goes.

claremacrae commented 3 years ago

Hi, thanks very much indeed for this...

Initial experiments with it looked promising, and then I got a traceback... so I'll make notes here, and see if I can figure out a repro..

The traceback: ``` java.util.concurrent.ExecutionException: com.intellij.openapi.progress.ProcessCanceledException at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395) at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999) at net.zero9178.cov.data.LLVMCoverageGenerator.processRoot(LLVMCoverageGenerator.kt:209) at net.zero9178.cov.data.LLVMCoverageGenerator.processJson(LLVMCoverageGenerator.kt:154) at net.zero9178.cov.data.LLVMCoverageGenerator.generateCoverage(LLVMCoverageGenerator.kt:592) at net.zero9178.cov.CoverageConfigurationExtension$attachToProcess$1$processTerminated$2.run(CoverageConfigurationExtension.kt:140) at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:962) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:472) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:235) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:235) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: com.intellij.openapi.progress.ProcessCanceledException at com.jetbrains.cidr.lang.parser.OCParser.computeSyncWithEDTPriority(OCParser.java:353) at com.jetbrains.cidr.lang.parser.OCParser.parse(OCParser.java:198) at com.jetbrains.cidr.lang.parser.OCFileElementType.parseContents(OCFileElementType.java:23) at com.intellij.psi.impl.source.tree.LazyParseableElement.lambda$ensureParsed$0(LazyParseableElement.java:192) at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:567) at com.intellij.psi.impl.source.tree.LazyParseableElement.ensureParsed(LazyParseableElement.java:191) at com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:242) at com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:42) at com.intellij.psi.impl.source.tree.SharedImplUtil.getFirstChild(SharedImplUtil.java:37) at com.intellij.psi.impl.source.PsiFileImpl.getFirstChild(PsiFileImpl.java:744) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1$1.visitElement(LLVMCoverageGenerator.kt:392) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1.compute(LLVMCoverageGenerator.kt:514) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1.compute(LLVMCoverageGenerator.kt:37) at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$0(DumbService.java:103) at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$1(DumbService.java:147) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:889) at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:61) at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:140) at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:103) at net.zero9178.cov.data.LLVMCoverageGenerator.findStatementsForBranches(LLVMCoverageGenerator.kt:367) at net.zero9178.cov.data.LLVMCoverageGenerator.processFunctions(LLVMCoverageGenerator.kt:281) at net.zero9178.cov.data.LLVMCoverageGenerator.access$processFunctions(LLVMCoverageGenerator.kt:37) at net.zero9178.cov.data.LLVMCoverageGenerator$processRoot$$inlined$flatMap$lambda$1.get(LLVMCoverageGenerator.kt:207) at net.zero9178.cov.data.LLVMCoverageGenerator$processRoot$$inlined$flatMap$lambda$1.get(LLVMCoverageGenerator.kt:37) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692) 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:183) ```
claremacrae commented 3 years ago

Steps done:

  1. Delete all configurations with coverage on - both in CMake settings. and on disk
  2. Select Debug-clang+llvm-11
  3. Run with C//C++ Coverage Plugin
  4. Click "Create" on the missing compilation flags dialog - and wait for CMake project to reload
    [I think the 'Missing compilation flags' popup didn't disappear after the new profile had loaded.
  5. Run the CLion coverage button
    CLion coverage results updated correctly
  6. Run the C/C++ Coverage Plugin
    No results displayed - red exclamation warning shows up at bottom right
Traceback ``` java.util.concurrent.ExecutionException: com.intellij.openapi.progress.ProcessCanceledException at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395) at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999) at net.zero9178.cov.data.LLVMCoverageGenerator.processRoot(LLVMCoverageGenerator.kt:209) at net.zero9178.cov.data.LLVMCoverageGenerator.processJson(LLVMCoverageGenerator.kt:154) at net.zero9178.cov.data.LLVMCoverageGenerator.generateCoverage(LLVMCoverageGenerator.kt:592) at net.zero9178.cov.CoverageConfigurationExtension$attachToProcess$1$processTerminated$2.run(CoverageConfigurationExtension.kt:140) at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:962) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:472) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:235) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:235) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: com.intellij.openapi.progress.ProcessCanceledException at com.jetbrains.cidr.lang.parser.OCParser.computeSyncWithEDTPriority(OCParser.java:353) at com.jetbrains.cidr.lang.psi.impl.OCLazyElementBase.getFirstChildNode(OCLazyElementBase.java:144) at com.intellij.psi.impl.source.tree.LazyParseablePsiElement.getFirstChild(LazyParseablePsiElement.java:88) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1$1.visitElement(LLVMCoverageGenerator.kt:392) at com.jetbrains.cidr.lang.psi.visitors.OCVisitor.visitOCElement(OCVisitor.java:13) at com.jetbrains.cidr.lang.psi.visitors.OCVisitor.visitStatement(OCVisitor.java:25) at com.jetbrains.cidr.lang.psi.visitors.OCVisitor.visitBlockStatement(OCVisitor.java:33) at com.jetbrains.cidr.lang.psi.impl.OCLazyBlockStatementImpl.accept(OCLazyBlockStatementImpl.java:28) at com.jetbrains.cidr.lang.psi.impl.OCLazyElementBase.accept(OCLazyElementBase.java:78) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1$1.visitElement(LLVMCoverageGenerator.kt:396) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1$1.visitElement(LLVMCoverageGenerator.kt:398) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1$1.visitElement(LLVMCoverageGenerator.kt:398) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1.compute(LLVMCoverageGenerator.kt:514) at net.zero9178.cov.data.LLVMCoverageGenerator$findStatementsForBranches$1.compute(LLVMCoverageGenerator.kt:37) at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$0(DumbService.java:103) at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$1(DumbService.java:147) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:889) at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:61) at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:140) at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:103) at net.zero9178.cov.data.LLVMCoverageGenerator.findStatementsForBranches(LLVMCoverageGenerator.kt:367) at net.zero9178.cov.data.LLVMCoverageGenerator.processFunctions(LLVMCoverageGenerator.kt:281) at net.zero9178.cov.data.LLVMCoverageGenerator.access$processFunctions(LLVMCoverageGenerator.kt:37) at net.zero9178.cov.data.LLVMCoverageGenerator$processRoot$$inlined$flatMap$lambda$1.get(LLVMCoverageGenerator.kt:207) at net.zero9178.cov.data.LLVMCoverageGenerator$processRoot$$inlined$flatMap$lambda$1.get(LLVMCoverageGenerator.kt:37) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692) 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:183) ```

The traceback in the previous comment was also generated with this sequence of steps.

claremacrae commented 3 years ago

The "happy path" works well:

  1. Restart CLion (2020.3, still)
  2. Delete all configurations with coverage on - both in CMake settings. and on disk
  3. Select Debug-clang+llvm-11
  4. Run with C//C++ Coverage Plugin
  5. Click "Create" on the missing compilation flags dialog - and wait for CMake project to reload
  6. Run the C/C++ Coverage Plugin
    Success - results are displayed

It does seem that the traceback might be to do with running the CLion run-with-coverage button before running the Plugin's run-with-coverage button.

zero9178 commented 3 years ago

Last I looked into this it was related to CLion being under high load as other tasks are running (due to say indexing or otherwise). Waiting for those to stop before running coverage would be a workaround.

I will try to look into this again and hope I can somehow give coverage higher priority so that CLion doesn't try to cancel it.

claremacrae commented 3 years ago

I should say that today I am testing it on a slightly larger project than over the last few days... so that may well be related...

claremacrae commented 3 years ago

In the interests of full disclosure - about the amount of your time that I am using on this project - I thought I should let you know that this CLion ticket seems to be getting a lot of attention at the moment, in terms of the number of email messages I've been receiving about it changing state (to test, to dev etc)

Add proper branch coverage: https://youtrack.jetbrains.com/issue/CPP-22202

I'd hate for you to spend loads of time on this, only to find that a CLion update makes this plugin redundant...

(The gap in functionality between the two options is currently so great that I think it's probably unlikely that the new CLion feature will overtake the plugin... but I did feel compelled to make sure you were aware that JetBrains is working on this...)

claremacrae commented 3 years ago

I should say that today I am testing it on a slightly larger project than over the last few days... so that may well be related...

I'l go back to testing the previous project, and see what happens...

claremacrae commented 3 years ago

Last I looked into this it was related to CLion being under high load as other tasks are running (due to say indexing or otherwise). Waiting for those to stop before running coverage would be a workaround.

Yes, still on the larger project, if I leave a longer gap between running CLion coverage and then plugin coverage, the plugin coverage works fine.

[I tried reproducing it working fine, and got a CLion low-memory warning]

claremacrae commented 3 years ago

Rats - I've just realised that all these comments today should have gone in to #25... Sorry.

zero9178 commented 3 years ago

In the interests of full disclosure - about the amount of your time that I am using on this project - I thought I should let you know that this CLion ticket seems to be getting a lot of attention at the moment, in terms of the number of email messages I've been receiving about it changing state (to test, to dev etc)

Add proper branch coverage: https://youtrack.jetbrains.com/issue/CPP-22202

I'd hate for you to spend loads of time on this, only to find that a CLion update makes this plugin redundant...

(The gap in functionality between the two options is currently so great that I think it's probably unlikely that the new CLion feature will overtake the plugin... but I did feel compelled to make sure you were aware that JetBrains is working on this...)

Don't worry about it. I am also quite actively looking at CLions bug tracker so I do know they are working on it. Unless they are equal on features, that is both in terms of annotating branch coverage as well as the nice region coverage clang provides, I am not planning to stop development on this plugin. And if they do end up finally having all those features I will likely be celebrating! I would rather have a great coverage functionality in CLion than an ego boost due to downloads on my plugin. Any time I spend on it I do for fun and I see as already worthwhile. Although I do admit that seeing bug reports as well as people using the plugin gives me more motivation and more of an incentive to work on it as opposed to other projects of mine.

claremacrae commented 3 years ago

That's really kind - thank you very much!