zero9178 / C-Cpp-Coverage-for-CLion

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

[2.11] Exception with Clang(8/9) #16

Open ja-b opened 5 years ago

ja-b commented 5 years ago

Getting the current exception at the time of coverage report generation on clang 8 and 9.

java.lang.IndexOutOfBoundsException: fromIndex (-1) is less than zero.
    at kotlin.collections.CollectionsKt__CollectionsKt.rangeCheck$CollectionsKt__CollectionsKt(Collections.kt:371)
    at kotlin.collections.CollectionsKt__CollectionsKt.binarySearch(Collections.kt:344)
    at net.zero9178.cov.data.LLVMCoverageGenerator$processJson$$inlined$flatMap$lambda$1.call(LLVMCoverageGenerator.kt:556)
    at net.zero9178.cov.data.LLVMCoverageGenerator$processJson$$inlined$flatMap$lambda$1.call(LLVMCoverageGenerator.kt:33)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:322)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    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.lang.Thread.run(Thread.java:834)

Induced Exception:

java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.collections.CollectionsKt__MutableCollectionsKt.addAll, parameter elements
    at kotlin.collections.CollectionsKt__MutableCollectionsKt.addAll(MutableCollections.kt)
    at net.zero9178.cov.data.LLVMCoverageGenerator.processJson(LLVMCoverageGenerator.kt:610)
    at net.zero9178.cov.data.LLVMCoverageGenerator.generateCoverage(LLVMCoverageGenerator.kt:534)
    at net.zero9178.cov.CoverageConfigurationExtension$attachToProcess$1$processTerminated$1.run(CoverageConfigurationExtension.kt:111)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:894)
    at com.intellij.openapi.progress.impl.CoreProgressManager$5.run(CoreProgressManager.java:447)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:169)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:591)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:537)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:156)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$null$9(ApplicationImpl.java:552)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:294)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    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.lang.Thread.run(Thread.java:834)
zero9178 commented 5 years ago

This is caused by this line: https://github.com/zero9178/C-Cpp-Coverage-for-CLion/blob/066cbcec99267b79c46fb16d896786a3ab542a70/src/main/kotlin/net/zero9178/cov/data/LLVMCoverageGenerator.kt#L167

funcStart is returning -1 which means that when trying to calculate branch coverage it somehow didn't find the function. This could be caused by an incorrect expression inside the filter function above but I have no clue. Easiest way would be to skip the function if funcStart is negative but that is probably the lazy and incorrect solution and the problem is somewhere deeper.

Do you by any chance have a C or C++ source file(s) that I could compile and run to reproduce this issue?

ja-b commented 5 years ago

Sure, I'll try to run with more isolated cases and send one of those your way.

zero9178 commented 5 years ago

C C++ Coverage-2019.2.0.zip I have created a version of the plugin that should send you a notification of what the function is called right before the exception happens. Should help you find the function causing it and hopefully isolate the case