Search code examples
c++githubcicdgcov

gcov command returns -11 on github pipeline, but works fine on a local computer


I am trying to setup a code coverage build for my C++ project and I cannot get it to work as a github workflow pipeline. The exact same script (so I think) works on my local computer. It is probably one of those obvious problems that only others can find (I am still new to github pipelines), so I feel sorry for asking.

I did set up a dummy repository to show the problem. The relevant part of the workflow file is:

      - name: Configure
        env:
          CXXFLAGS: --coverage -fprofile-abs-path -g -O0
          CFLAGS: --coverage -fprofile-abs-path -g -O0
          LDFLAGS: --coverage
          CC: gcc-13
          CXX: g++-13
        run: cmake -S . -B build

      - name: Build
        run: cmake --build build

      - name: Execute
        run: ./build/main

      - name: Create report
        run: |
          mkdir build/html
          which gcov
          gcovr -v --gcov-executable /usr/bin/gcov --print-summary -x build/coverage.xml --html-details build/html/index.html -r . build

The script I tried on my local computer is:

git clone [email protected]:yobeonline/gcov_test.git
cd gcov_test/
export CXXFLAGS="--coverage -fprofile-abs-path -g -O0"
export CFLAGS="--coverage -fprofile-abs-path -g -O0"
export LDFLAGS="--coverage"
cmake -S . -B build
cmake --build build
./build/main
mkdir build/html
gcovr --gcov-executable /usr/bin/gcov --print-summary -x build/coverage.xml --html-details build/html/index.html -r . build

The output I have is what I expected:

lines: 10.0% (2 out of 20)
functions: 33.3% (1 out of 3)
branches: 0.0% (0 out of 0)
calls: 0.0% (0 out of 0)

Wherease github pipeline gives (verbose on) (see here)

(DEBUG) File system is case sensitive.
(DEBUG) Filters for --root: (1)
(DEBUG)  - re.compile('^/home/runner/work/gcov_test/gcov_test/')
(DEBUG) Filters for --filter: (1)
(DEBUG)  - DirectoryPrefixFilter(/home/runner/work/gcov_test/gcov_test/)
(DEBUG) Filters for --exclude: (0)
(DEBUG) Filters for --gcov-filter: (1)
(DEBUG)  - AlwaysMatchFilter()
(DEBUG) Filters for --gcov-exclude: (0)
(DEBUG) Filters for --gcov-exclude-directories: (0)
(INFO) Reading coverage data...
(DEBUG) Scanning directory build for gcda/gcno files...
(DEBUG) Found 4 files (and will process 3)
(DEBUG) Pool started with 1 threads
(DEBUG) Processing file: /home/runner/work/gcov_test/gcov_test/build/CMakeFiles/main.dir/main.cpp.gcda
(DEBUG) Running gcov: '/usr/bin/gcov --help' in '.'
(DEBUG) Running gcov: '/usr/bin/gcov --help-hidden' in '.'
(DEBUG) Running gcov: '/usr/bin/gcov /home/runner/work/gcov_test/gcov_test/build/CMakeFiles/main.dir/main.cpp.gcda --branch-counts --branch-probabilities --all-blocks --demangled-names --hash-filenames --object-directory build/CMakeFiles/main.dir' in '/home/runner/work/gcov_test/gcov_test'
(ERROR) Trouble processing '/home/runner/work/gcov_test/gcov_test/build/CMakeFiles/main.dir/main.cpp.gcda' with working directory '/home/runner/work/gcov_test/gcov_test'.
Stdout of gcov was >>None<< End of stdout
Stderr of gcov was >>None<< End of stderr
Current processed gcov file was None.
Use option --verbose to get extended information.
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 422, in process_datafile
    done = run_gcov_and_process_files(
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 661, in run_gcov_and_process_files
    out, err = gcov_cmd.run_with_args(
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 622, in run_with_args
    raise RuntimeError(
RuntimeError: GCOV returncode was -11 (exited by signal).
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 422, in process_datafile
    done = run_gcov_and_process_files(
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 661, in run_gcov_and_process_files
    out, err = gcov_cmd.run_with_args(
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 622, in run_with_args
    raise RuntimeError(
RuntimeError: GCOV returncode was -11 (exited by signal).
(ERROR) Error occurred while reading reports:
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/__main__.py", line 362, in main
    covdata: CovData = gcovr_formats.read_reports(options)
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/__init__.py", line 66, in read_reports
    covdata = GcovHandler(options).read_report()
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/__init__.py", line 202, in read_report
    return read_report(self.options)
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 79, in read_report
    with Workers(
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/workers.py", line 173, in __exit__
    self.wait()
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/workers.py", line 164, in wait
    raise self.exceptions[0][1]
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 86, in read_report
    contexts = pool.wait()
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/workers.py", line 164, in wait
    raise self.exceptions[0][1]
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 422, in process_datafile
    done = run_gcov_and_process_files(
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 661, in run_gcov_and_process_files
    out, err = gcov_cmd.run_with_args(
  File "/home/runner/.local/lib/python3.10/site-packages/gcovr/formats/gcov/read.py", line 622, in run_with_args
    raise RuntimeError(
RuntimeError: GCOV returncode was -11 (exited by signal).

Solution

  • When the behaviour between running things locally and in Actions, it's sometimes due to differing versions in the two environments.

    I would add lines to the workflow to display the version of gcc and gcov used and then try locally with the same version, if it's different.