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

lcov fails with gcc 14 #296

Closed
Klaus33333 opened this issue May 24, 2024 · 11 comments
Closed

lcov fails with gcc 14 #296

Klaus33333 opened this issue May 24, 2024 · 11 comments

Comments

@Klaus33333
Copy link

I tried to run my coverage reports and got the following errors:

lcov --gcov-tool gcov --base-directory . --directory ./build/ --directory ./ -c -o ./build/test_coverage_report.info
Capturing coverage data from ./build/ ./
geninfo cmd: '/usr/bin/geninfo ./build/ ./ --output-filename ./build/test_coverage_report.info --gcov-tool gcov --base-directory . --memory 0'
geninfo: WARNING: Duplicate specification "base-directory|b=s" for option "b"
Found gcov version: 14.1.1
Using intermediate gcov format
Writing temporary data to /tmp/geninfo_datG4GC
Scanning ./build/ for .gcda files ...
Found 31 data files in ./build/

Processing ./build/file1.gcda
geninfo: WARNING: /file1.c:2811: unexecuted block on non-branch line with non-zero hit count. Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
Processing ./build/build-utradgw-std-rsysg-nomemdbg-o2-dynamic-cov/test1.gcda
geninfo: WARNING: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:100: unexecuted block on non-branch line with non-zero hit count. Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
(use "geninfo --ignore-errors gcov,gcov ..." to suppress this warning)
geninfo: ERROR: mismatched end line for _ZN17TEST1_SUITE1_Test8TestBodyEv at /home/krud/git_my_checkout/rrs/radgw/test1.cpp:9: 9 -> 19
(use "geninfo --ignore-errors mismatch ..." to bypass this error)

I found some similar report in this mailing archive: https://www.mail-archive.com/[email protected]/msg101150.html

Do I have any chance of a workaround or even better a fix :-)

Thanks!

@henry2cox
Copy link
Collaborator

I fear that I'm not entirely sure which fixes/workarounds you are looking for.
It appears that we see two different errors/inconsistencies in the gcov data for this testcase:

  1. function _ZN17TEST1_SUITE1_Test8TestBodyEv is found to end on line .../test1.cpp:9 in one GCDA file but is found to end on line 19 in another file.
    This appears to be a bug in gcov (or in gcc) which turns up sometimes (...which is why lcov checks for it).
    lcov uses the function range to figure out which coverpoints belong to the function, in order to support function-level exclusion and also to report covered proportions.
    You can safely ignore the error if you don't care about those features.
    To work around it is a bit painful - as you would have to manually fix the start/end lines (e.g., via sed on the data file)...or possibly someone can fix it in gcc/gcov.

  2. The gcov output data is not consistent at line file1.c:2811.
    I fear that I have forgotten the details, but the comment near line geninfo:2324 suggests that the report will look weird because we will see a block inside some conditional (say, the 'if' clause) such that the 'if' expression is not evaluated but the statement is hit.
    The suggested workaround is to tell geninfo to set the block hit count to zero when that happens (or gcc/gcov need to fix the bug).
    To see how the second issue affects your coverage report: capture your coverage data twice - once setting the count and once without, then generate a differential coverage report (genhtml -o whatTheHeck --baseline-file without.info with.info ...) and inspect the differences.

@henry2cox
Copy link
Collaborator

Closing this issue now.
There appears to be a bug or bugs in gcc/14 (and/or in the corresponding gcov) which causes gcov to generate coverage data which is inconsistent in several ways.
lcov (geninfo) reports about these inconsistencies - and also allows you to ignore them and continue anyway.

If you think that there is still an lcov bug here, please feel free to reopen this issue or file a new one.
Please include a detailed description of the problem and (ideally) include a small testcase which exhibits the issue.
Thanks
Henry

@WillAyd
Copy link

WillAyd commented Dec 19, 2024

Thanks @henry2cox for all of the info on this thread. Is there already a bug report upstream in gcc for this that can be tracked?

If not I'd be happy to open one, although my understanding of how to identify and properly communicate the root cause is limited

@henry2cox
Copy link
Collaborator

I don't know of any related bugs filed against either GCC or LLVM (both have bugs...we all have bugs).
Please feel free to go ahead and file one. Your testcase could be a good example for them to look at.

WRT how to identify: the gcov output is what lcov is reading - and the error will be obvious there (run lcov to have it tell you where the error is, then highlight that in your gcc/llvm report). It isn't clear if the issues are in gcc (llvm) generating the data (very likely) or gcov (llvm-cov) extracting it.
I suspect that the line numbering bug is far more straightforward than the block count bug.

Yet another workaround that I forgot to mention, is to exclude either the files which contain fishy data (see the --exclude section in the man page) or just the function(s) (see the --erase-functions section). (Of course, the latter depends on end line information - and so is affected by the very bug it is trying to work around.)

@WillAyd
Copy link

WillAyd commented Dec 23, 2024

When you refer to the gcc/llvm report are you asking about the .info file? I see an error like:

geninfo: ERROR: mismatched end line for _ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv at /home/willayd/clones/arrow-nanoarrow/src/nanoarrow/hpp/buffer_test.cc:41: 41 -> 56

I can trace that function back to a line in the *gcda.info file with these contents:

FN:41,41,_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv

Back in Ubuntu 22.04 it appears as if this was the line being generated:

FN:41,_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv

Does the added 41, indicate the issue or am I looking in the wrong place?

FWIW I'm running this all through the ninja / meson wrapper. The inner workings of how those dispatch to lcov and how that relates to gcov / gcc are a bit foreign to me, though I can see from the meson logs it executes this command on failure:

lcov --directory <build_dir> --capture --initial --output-file <output_file>

@henry2cox
Copy link
Collaborator

Sorry to have been incomplete/confusing.
geninfo (which is invoked by lcov --capture ..) is very simple: it calls your gcov, passing some flags and then parses the result to turn it into an lcov data file.
In this case, it is almost certainly using flags gcov -i -c -p your_data.gcda (though you can see exactly what it called, by adding some verbosity flags to your lcov (or geninfo) command: lcov --verbose --verbose --capture ...

In your case, at least one file containing data for that function was .../buffer_test.cc - which almost certainly comes from .../buffer_test.gcda. Unfortunately: we don't know (yet) which other GCDA file contained the conflicting information.

  • execute the gcov command locally - so you can look at the gcov output - to demonstrate that it is wrong:
    gcov -i -c -p .../buffer_test.gcda - and look at the output (which will be something ending in .gcov
  • alternately, you can pass the --preserve flag to lcov/geninfo - to tell it to not delete the internally generated gcov data.
    The only issue there is that it will be using random looking directory names - so it will be a bit painful to find exactly the data you are looking for (but find is your friend - and we know the name of the function that we are looking for).

From that gcov data: we can find two records for _ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv in the generated JSON output, at least one of which says that the function end line is 41 and at least one which says it is 56. They cannot both be right (and might both be wrong).
Whichever one is wrong: is proof that either gcc generated incorrect data (.gcno/.gcda) or gcov did.

The lcov output you show, above - is simply the parsed result of merging the gcov-generated data into lcov format.

  • The first record you show, shows the function begin line (41) and end line (also 41).
  • The second record shows the function begin line (41) but doesn't contain end line information (...which is optional).
    This is either because that version of gcc/gcov did not generate the data, or because that version of lcov was old enough that it did not support function end line processing.

I hope this helps.

Henry

@WillAyd
Copy link

WillAyd commented Dec 26, 2024

Thanks for the steps. I am inspecting the gcov output but I don't think I am seeing exactly what you described. There is only one entry with that function name that looks like this:

        {
          "name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "demangled_name": "HppBuffer_BufferInitWrapped_Test::TestBody()",
          "start_line": 41,
          "start_column": 1,
          "end_line": 56,
          "end_column": 1,
          "blocks": 99,
          "blocks_executed": 22,
          "execution_count": 1
        },

In the lines key I see this information for the function:

        {
          "line_number": 41,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": false,
          "branches": []
        },
        {
          "line_number": 42,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": false,
          "branches": []
        },
        {
          "line_number": 43,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": false,
          "branches": []
        },
        {
          "line_number": 46,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": false,
          "branches": []
        },
        {
          "line_number": 47,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": true,
          "branches": []
        },
        {
          "line_number": 48,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": true,
          "branches": []
        },
        {
          "line_number": 50,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": true,
          "branches": []
        },
        {
          "line_number": 55,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": true,
          "branches": []
        },
        {
          "line_number": 56,
          "function_name": "_ZN32HppBuffer_BufferInitWrapped_Test8TestBodyEv",
          "count": 1,
          "unexecuted_block": false,
          "branches": []
        },

@WillAyd
Copy link

WillAyd commented Dec 26, 2024

Just a few other assorted things I've noticed so far.

or just the function(s) (see the --erase-functions section)

FWIW the version of lcov I get with ubuntu 24.04 is 2.0-1. I see from another issue that the PR implementing that keyword is 10c6ea0 and is tagged 2.3. I don't get a failure message using that argument, but it also doesn't seem to have any effect, so maybe its a version thing?

If I try to exclude the offending file altogether I can work around the immediate issue, but there are more files affected in the code base (FWIW they all use googletest, so might be something specifically with that library). However, after excluding all of the files I still get the following error from lcov:

geninfo: WARNING: /usr/include/c++/13/bits/hashtable.h:592: unexecuted block on non-branch line with non-zero hit count.  Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
geninfo: ERROR: "/usr/include/c++/13/bits/vector.tcc":469: mismatched exception tag for id 1, 1: '0' -> '1'
	(use "geninfo --ignore-errors mismatch ..." to bypass this error)

The larger traceback is provided below, in case that is helpful

ninja coverage
[1/1] Generates coverage reports
FAILED: meson-internal__coverage 
/home/willayd/miniforge3/envs/pantab-dev/bin/meson --internal coverage /home/willayd/clones/arrow-nanoarrow /home/willayd/clones/arrow-nanoarrow/subprojects /home/willayd/clones/arrow-nanoarrow/builddir /home/willayd/clones/arrow-nanoarrow/builddir/meson-logs
Capturing coverage data from /home/willayd/clones/arrow-nanoarrow/builddir
geninfo cmd: '/usr/bin/geninfo /home/willayd/clones/arrow-nanoarrow/builddir --output-filename /home/willayd/clones/arrow-nanoarrow/builddir/meson-logs/coverage.info.initial --initial --config-file /home/willayd/clones/arrow-nanoarrow/.lcovrc --exclude nanoarrow/hpp/buffer_test.cc --exclude nanoarrow/integration/c_data_integration_test.cc --exclude nanoarrow/common/schema_test.cc --exclude nanoarrow/common/buffer_test.cc --exclude src/nanoarrow/common/array_stream_test.cc --exclude nanoarrow/hpp/exception_test.cc --exclude nanoarrow/hpp/array_stream_test.cc --exclude nanoarrow/hpp/unique_test.cc --exclude nanoarrow/common/array_test.cc --exclude src/nanoarrow/hpp/view_test.cc --exclude nanoarrow/common/utils_test.cc --memory 0'
Found gcov version: 13.3.0
Using intermediate gcov format
Writing temporary data to /tmp/geninfo_dat7vvh
Scanning /home/willayd/clones/arrow-nanoarrow/builddir for .gcno files ...
Found 49 graph files in /home/willayd/clones/arrow-nanoarrow/builddir
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-buffer-test.p/src_nanoarrow_hpp_buffer_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-buffer-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-buffer-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-buffer-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/libnanoarrow_testing.so.p/src_nanoarrow_testing_testing.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/c-data-integration-test.p/src_nanoarrow_integration_c_data_integration_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/c-data-integration-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/c-data-integration-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/schema-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/schema-test.p/src_nanoarrow_common_schema_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/schema-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/schema-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/buffer-test.p/src_nanoarrow_common_buffer_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/buffer-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/buffer-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/buffer-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-stream-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-stream-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-stream-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-stream-test.p/src_nanoarrow_common_array_stream_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/libnanoarrow.so.p/src_nanoarrow_common_array_stream.c.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/libnanoarrow.so.p/src_nanoarrow_common_utils.c.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/libnanoarrow.so.p/src_nanoarrow_common_array.c.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/libnanoarrow.so.p/src_nanoarrow_common_schema.c.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-exception-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-exception-test.p/src_nanoarrow_hpp_exception_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-exception-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-exception-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-array_stream-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-array_stream-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-array_stream-test.p/src_nanoarrow_hpp_array_stream_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-array_stream-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-unique-test.p/src_nanoarrow_hpp_unique_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-unique-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-unique-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-unique-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/libnanoarrow_c_data_integration.so.p/src_nanoarrow_integration_c_data_integration.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-test.p/src_nanoarrow_common_array_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/array-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/utils-test.p/src_nanoarrow_common_utils_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/utils-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/utils-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/utils-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-view-test.p/src_nanoarrow_hpp_view_test.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-view-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-view-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcno
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-view-test.p/subprojects_googletest-1.14.0_googlemock_src_gmock-all.cc.gcno
Excluded data for 11 files due to include/exclude options
Finished .info-file creation
Capturing coverage data from /home/willayd/clones/arrow-nanoarrow/builddir
geninfo cmd: '/usr/bin/geninfo /home/willayd/clones/arrow-nanoarrow/builddir --output-filename /home/willayd/clones/arrow-nanoarrow/builddir/meson-logs/coverage.info.run --no-checksum --rc branch_coverage=1 --config-file /home/willayd/clones/arrow-nanoarrow/.lcovrc --exclude nanoarrow/hpp/buffer_test.cc --exclude nanoarrow/integration/c_data_integration_test.cc --exclude nanoarrow/common/schema_test.cc --exclude nanoarrow/common/buffer_test.cc --exclude src/nanoarrow/common/array_stream_test.cc --exclude nanoarrow/hpp/exception_test.cc --exclude nanoarrow/hpp/array_stream_test.cc --exclude nanoarrow/hpp/unique_test.cc --exclude nanoarrow/common/array_test.cc --exclude src/nanoarrow/hpp/view_test.cc --exclude nanoarrow/common/utils_test.cc --memory 0 --branch-coverage'
Found gcov version: 13.3.0
Using intermediate gcov format
Writing temporary data to /tmp/geninfo_datRlmz
Scanning /home/willayd/clones/arrow-nanoarrow/builddir for .gcda files ...
Found 49 data files in /home/willayd/clones/arrow-nanoarrow/builddir
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-buffer-test.p/subprojects_googletest-1.14.0_googletest_src_gtest_main.cc.gcda
Processing /home/willayd/clones/arrow-nanoarrow/builddir/hpp-buffer-test.p/subprojects_googletest-1.14.0_googletest_src_gtest-all.cc.gcda
geninfo: WARNING: /usr/include/c++/13/bits/hashtable.h:592: unexecuted block on non-branch line with non-zero hit count.  Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
geninfo: ERROR: "/usr/include/c++/13/bits/vector.tcc":469: mismatched exception tag for id 1, 1: '0' -> '1'
	(use "geninfo --ignore-errors mismatch ..." to bypass this error)
Traceback (most recent call last):
  File "/home/willayd/miniforge3/envs/pantab-dev/bin/meson", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/willayd/miniforge3/envs/pantab-dev/lib/python3.13/site-packages/mesonbuild/mesonmain.py", line 293, in main
    return run(sys.argv[1:], launcher)
  File "/home/willayd/miniforge3/envs/pantab-dev/lib/python3.13/site-packages/mesonbuild/mesonmain.py", line 281, in run
    return run_script_command(args[1], args[2:])
  File "/home/willayd/miniforge3/envs/pantab-dev/lib/python3.13/site-packages/mesonbuild/mesonmain.py", line 222, in run_script_command
    return module.run(script_args)
           ~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/willayd/miniforge3/envs/pantab-dev/lib/python3.13/site-packages/mesonbuild/scripts/coverage.py", line 213, in run
    return coverage(options.outputs, options.source_root,
                    options.subproject_root, options.build_root,
                    options.log_dir, options.use_llvm_cov,
                    options.gcovr, options.llvm_cov)
  File "/home/willayd/miniforge3/envs/pantab-dev/lib/python3.13/site-packages/mesonbuild/scripts/coverage.py", line 121, in coverage
    subprocess.check_call([lcov_exe,
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
                           '--directory', build_root,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
                          lcov_config +
                          ^^^^^^^^^^^^^
                          gcov_tool_args)
                          ^^^^^^^^^^^^^^^
  File "/home/willayd/miniforge3/envs/pantab-dev/lib/python3.13/subprocess.py", line 419, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lcov', '--directory', '/home/willayd/clones/arrow-nanoarrow/builddir', '--capture', '--output-file', '/home/willayd/clones/arrow-nanoarrow/builddir/meson-logs/coverage.info.run', '--no-checksum', '--rc', 'branch_coverage=1', '--config-file', '/home/willayd/clones/arrow-nanoarrow/.lcovrc']' returned non-zero exit status 1.
ninja: build stopped: subcommand failed.

The fact that those errors point to the stdlib makes me even more uncertain - is there perhaps an issue with the 2.0-1 version that comes bundled with ubuntu 24.04,?

@WillAyd
Copy link

WillAyd commented Dec 26, 2024

Also unsure if this matters to the lcov project at all but it appears that gcovr is able to produce coverage reports against the same code base

@WillAyd
Copy link

WillAyd commented Dec 26, 2024

...and one potentially last useful bit of information is that lcov-2.2 doesn't have the issue from the OP but does end up with an error similar to #296 (comment)

/usr/bin/meson --internal coverage /data /data/subprojects /data/builddir2 /data/builddir2/meson-logs
genhtml: LCOV version 2.2-1
Capturing coverage data from /data/builddir2
geninfo cmd: '/usr/local/bin/geninfo /data/builddir2 --output-filename /data/builddir2/meson-logs/coverage.info.initial --initial --config-file /data/.lcovrc --exclude nanoarrow/hpp/buffer_test.cc --exclude nanoarrow/integration/c_data_integration_test.cc --exclude nanoarrow/common/schema_test.cc --exclude nanoarrow/common/buffer_test.cc --exclude src/nanoarrow/common/array_stream_test.cc --exclude nanoarrow/hpp/exception_test.cc --exclude nanoarrow/hpp/array_stream_test.cc --exclude nanoarrow/hpp/unique_test.cc --exclude nanoarrow/common/array_test.cc --exclude src/nanoarrow/hpp/view_test.cc --exclude nanoarrow/common/utils_test.cc'
Found gcov version: 13.3.0
Using intermediate gcov format
Recording 'internal' directories:
	/data/builddir2
Writing temporary data to /tmp/geninfo_datV99V
Scanning /data/builddir2 for .gcno files ...
Found 49 graph files in /data/builddir2
using: chunkSize: 1, nchunks:49, intervalLength:2
geninfo: WARNING: using JSON module "JSON::PP" - which is much slower than some alternatives.  Consider installing one of JSON::XS or Cpanel::JSON::XS
Excluding file '/data/src/nanoarrow/hpp/view_test.cc'
Excluding file '/data/src/nanoarrow/common/utils_test.cc'
Excluding file '/data/src/nanoarrow/common/array_test.cc'
Excluding file '/data/src/nanoarrow/hpp/unique_test.cc'
Excluding file '/data/src/nanoarrow/hpp/array_stream_test.cc'
Excluding file '/data/src/nanoarrow/hpp/exception_test.cc'
Excluding file '/data/src/nanoarrow/common/array_stream_test.cc'
Excluding file '/data/src/nanoarrow/common/buffer_test.cc'
Excluding file '/data/src/nanoarrow/common/schema_test.cc'
Excluding file '/data/src/nanoarrow/integration/c_data_integration_test.cc'
Excluding file '/data/src/nanoarrow/hpp/buffer_test.cc'
Finished processing 49 GCNO files
Excluded data for 11 files due to include/exclude options
Apply filtering..
Finished filter file processing
Finished .info-file creation
Summary coverage rate:
  source files: 117
  lines.......: 0.0% (0 of 12147 lines)
  functions...: 0.0% (0 of 2757 functions)
Filter suppressions:
  region:
    13 instances
Message summary:
  no messages were reported
Capturing coverage data from /data/builddir2
geninfo cmd: '/usr/local/bin/geninfo /data/builddir2 --output-filename /data/builddir2/meson-logs/coverage.info.run --no-checksum --branch-coverage --config-file /data/.lcovrc --rc branch_coverage=1 --exclude nanoarrow/hpp/buffer_test.cc --exclude nanoarrow/integration/c_data_integration_test.cc --exclude nanoarrow/common/schema_test.cc --exclude nanoarrow/common/buffer_test.cc --exclude src/nanoarrow/common/array_stream_test.cc --exclude nanoarrow/hpp/exception_test.cc --exclude nanoarrow/hpp/array_stream_test.cc --exclude nanoarrow/hpp/unique_test.cc --exclude nanoarrow/common/array_test.cc --exclude src/nanoarrow/hpp/view_test.cc --exclude nanoarrow/common/utils_test.cc'
Found gcov version: 13.3.0
Using intermediate gcov format
Recording 'internal' directories:
	/data/builddir2
Writing temporary data to /tmp/geninfo_datYPzA
Scanning /data/builddir2 for .gcda files ...
Found 49 data files in /data/builddir2
using: chunkSize: 1, nchunks:49, intervalLength:2
geninfo: WARNING: using JSON module "JSON::PP" - which is much slower than some alternatives.  Consider installing one of JSON::XS or Cpanel::JSON::XS
geninfo: WARNING: (inconsistent) /usr/include/c++/13/bits/unique_ptr.h:99: unexecuted block on non-branch line with non-zero hit count.  Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
	(use "geninfo --ignore-errors inconsistent,inconsistent ..." to suppress this warning)
Message summary:
  1 error message:
    mismatch: 1
  2 warning messages:
    inconsistent: 2
geninfo: WARNING: (inconsistent) /data/subprojects/googletest-1.14.0/googletest/src/gtest-internal-inl.h:439: unexecuted block on non-branch line with non-zero hit count.  Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
geninfo: ERROR: (mismatch) "/usr/include/c++/13/bits/stl_vector.h":606: mismatched exception tag for id 1, 1: '0' -> '1'

@henry2cox
Copy link
Collaborator

Also unsure if this matters to the lcov project at all but it appears that gcovr is able to produce coverage reports against the same code base

I haven't checked the gcovr implementation - but I very, very strongly suspect that the reason it is happy is that it doesn't check for errors and inconsistency in the data. You can get a similar effect by telling lcov to ignore certain errors, or to keep going despite errors. Note that the results you see from gcovr and lcov in that case might not be identical as they might treat the inconsistent data differently (e.g. first one wins, last one wins, drop, ...)

From your most recent update: it also seems that there may be some bug fixes and/or enhancements in lcov/2.2 and/or in TOT - so some messages no longer appear.
If you want to track down and report the remaining ones: the recipe is the same...look at the gcov-generated data for the offending coverpoints. For example, at least one compilation unit will report that the branch in question is related to an exception whereas at least one other will report that it is not - and so on.

mykola-kobets-epam added a commit to mykola-kobets-epam/aos_core_lib_cpp that referenced this issue Feb 14, 2025
gcov produces "geninfo: ERROR: mismatched end line" error msg, that
most likely produced by a bug in gcc

linux-test-project/lcov#296

Signed-off-by: Mykola Kobets <[email protected]>
mykola-kobets-epam added a commit to mykola-kobets-epam/aos_core_lib_cpp that referenced this issue Feb 14, 2025
gcov produces "geninfo: ERROR: mismatched end line" error msg, that
most likely produced by a bug in gcc

linux-test-project/lcov#296

Signed-off-by: Mykola Kobets <[email protected]>
mykola-kobets-epam added a commit to mykola-kobets-epam/aos_core_lib_cpp that referenced this issue Feb 18, 2025
gcov produces "geninfo: ERROR: mismatched end line" error msg, that
most likely produced by a bug in gcc
From: linux-test-project/lcov#296
"
There appears to be a bug or bugs in gcc/14(and/or in the corresponding
gcov) which causes gcov to generate coverage data which is inconsistent
in several ways.
"

Signed-off-by: Mykola Kobets <[email protected]>
j-i-k-o added a commit to OpenJij/OpenJij that referenced this issue Feb 27, 2025
## Changes
* Fix geninfo line number mismatch error
- We fixed a CI error that's occurring during the code coverage data
collection step for the C++ tests. The error is happening with the
geninfo tool and indicates a line number mismatch in the C++ hpp file.
- This appears to be a bug of gcc 14 as indicated in the issue
linux-test-project/lcov#296. Since [GitHub
Actions set the ubuntu-latest to
ubuntu-24.04](actions/runner-images#10636),
the default compiler is replaced with gcc 14.
- We fixed the error by adding `--ignore-errors mismatch` to `geninfo`.
  - The following process using gcov is temporarily skipped.

* Modify `setup.cfg` and test command
- modify `setup.cfg` by replacing `tests_require` with `extras_require`.
  - replace `python setup.py test` to `pytest`.
## Related issue

- linux-test-project/lcov#296
jijcloud-machine-user pushed a commit to OpenJij/OpenJij-Reference-Page that referenced this issue Feb 27, 2025
## Changes
* Fix geninfo line number mismatch error
- We fixed a CI error that's occurring during the code coverage data
collection step for the C++ tests. The error is happening with the
geninfo tool and indicates a line number mismatch in the C++ hpp file.
- This appears to be a bug of gcc 14 as indicated in the issue
linux-test-project/lcov#296. Since [GitHub
Actions set the ubuntu-latest to
ubuntu-24.04](actions/runner-images#10636),
the default compiler is replaced with gcc 14.
- We fixed the error by adding `--ignore-errors mismatch` to `geninfo`.
  - The following process using gcov is temporarily skipped.

* Modify `setup.cfg` and test command
- modify `setup.cfg` by replacing `tests_require` with `extras_require`.
  - replace `python setup.py test` to `pytest`.
## Related issue

- linux-test-project/lcov#296
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

3 participants