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

gcov 12 and 13 / lcov 2.0 version mismatch when collectin coverage with gcc 12 and 13 on ubuntu-24.04 #341

Open
mknaranja opened this issue Dec 17, 2024 · 3 comments

Comments

@mknaranja
Copy link

Describe the bug

With gcc, gcov, lcov my CI pipeline fails since version mismatches happen.

To Reproduce

Steps to reproduce the behavior:

More or less (see https://github.com/SciCompMod/GMGPolar/tree/main/.github/actions):

cmake -DCMAKE_BUILD_TYPE=Debug -DGMGPOLAR_TEST_COVERAGE=ON .. 
make -j4
cmake --build . --target coverage/fast 

Expected behavior

The code above works locally with lcov-1.14 and, e.g., gcc/gcov 12

Screenshots

With gcc/gcov 12 I get:

Capturing coverage data from .
geninfo cmd: '/usr/bin/geninfo . --output-filename coverage.base --gcov-tool /usr/bin/gcov-12 --base-directory /home/runner/work/GMGPolar/GMGPolar --initial --memory 0'
Found gcov version: 12.3.0
Using intermediate gcov format
Writing temporary data to /tmp/geninfo_datQy7t
Scanning . for .gcno files ...
Found 94 graph files in .
Processing ./tests/CMakeFiles/gmgpolar_tests.dir/comparetest.cpp.gcno
geninfo: ERROR: mismatched end line for _ZN42Test_Parameters_Initialize_Parameters_Test8TestBodyEv at /home/runner/work/GMGPolar/GMGPolar/tests/comparetest.cpp:47: 47 -> 52
	(use "geninfo --ignore-errors mismatch ..." to bypass this error)
gmake[1]: *** [CMakeFiles/coverage.dir/build.make:73: CMakeFiles/coverage] Error 1
gmake: *** [Makefile:174: coverage/fast] Error 2

see: https://github.com/SciCompMod/GMGPolar/actions/runs/12361346502/job/34498552858

With gcc/gcov 13 I get:

stderr:
  /home/runner/work/GMGPolar/GMGPolar/build/tests/CMakeFiles/gmgpolar_tests.dir/comparetest.cpp.gcno:version 'B33*', prefer 'B32*'
geninfo: ERROR: Incompatible GCC/GCOV version found while processing /home/runner/work/GMGPolar/GMGPolar/build/tests/CMakeFiles/gmgpolar_tests.dir/comparetest.cpp.gcno:
	Your test was built with 'B33*'.
	You are trying to capture with gcov tool '/usr/bin/gcov-13' which is version 'B32*'.
	(use "geninfo --ignore-errors version ..." to bypass this error)
gmake[1]: *** [CMakeFiles/coverage.dir/build.make:73: CMakeFiles/coverage] Error 1
gmake: *** [Makefile:174: coverage/fast] Error 2

see: https://github.com/SciCompMod/GMGPolar/actions/runs/12361745308/job/34499718252

Desktop (please complete the following information)

  • OS: GitHub ubuntu-latest
  • GCC version: gcc-12 and gcc-13 (github apt install gcc-12/13)
  • GCOVR version: gcov-12.3 and 13.2 (set with CMAKE and set(GCOV_PATH "/usr/bin/gcov-13"))
  • Project directory layout:
    • Roots
    • Object directories

Additional context

Appeared with recent move to ubuntu-24.04.

@henry2cox
Copy link
Collaborator

henry2cox commented Dec 17, 2024

Newer lcov does a fair amount of data consistency checking (...primarily due to sad history of confusing or misleading results).
Your first issue is one such.

  • Your function appears in more than one compilation unit (or appears multiple times in this particular gcov output) - and the 'end' line reported is different between the appearances.
  • A common cause is an incomplete build or mismatched libraries such that you are trying to merge data from two different versions of source code.
  • If you are certain that your build was complete and there is no version mismatch: then another common cause is a bug (or bugs) in your compiler. It turns out that the coverage infrastructure is not the most well tested feature on the planet - and it is extremely difficult to get right. My hat is off to the compiler guys :-)
    Unlike debug data (which simply confuses the debugger and/or the user when it is not right), coverage data leaves artifacts.

Your second issue is almost certainly an incomplete or incorrect build.
gcov is closely tied to gcc - and you must use the same version of both if you want to see correct result. It is possible that mixed versions of gcc/gcov will work - but there is no guarantee.

For both of these: the message also tells you what to do if you want to ignore the errors and continue.
See the --ignore-errors section in the man page for details.

When errors are downgraded: the tool tries to do something/tries its best guess. (There are some controls that you can use to tell lcov what to do in certain situations - see the man pages for details.)
Ignoring or suppressing errors might lead to additional errors and/or to confusing, misleading, or incorrect results. 'end line' errors are likely innocuous (mostly), and really affect only your ability to accurately exclude particular functions and associated coverpoints.

@mknaranja
Copy link
Author

Thank you for your response, it actually offers me/us the workaround of ignoring errors but I'd like to avoid such an option/workaround so I was searching for a true solution. We will check again with your comments.

@henry2cox
Copy link
Collaborator

If you think about it - the older versions were just silently ignoring all the errors and not telling you about them.

If you were happy with that behaviour: then you might be interested in the --keep-going flag :-)

On the other hand...if results don't have to be correct, then we can get them much faster.

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

No branches or pull requests

2 participants