You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Actions流水线执行gcov返回-11错误,但本地运行正常的问题求助

GitHub Actions流水线执行gcov返回-11错误,但本地运行正常的问题求助

大家好,我最近在给我的C++项目配置基于GitHub Actions的代码覆盖率构建流水线,但遇到了一个头疼的问题:本地运行完全正常的脚本,放到GitHub流水线里就报错了,gcov返回了-11的错误(信号退出)。我已经建了一个测试仓库来复现这个问题,下面是详细情况:

GitHub Actions流水线关键步骤

我的 workflow 里相关的步骤是这样的:

- 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

本地正常运行的脚本

我在本地执行的脚本和上面逻辑一致,具体内容:

git clone git@github.com: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

本地运行的正常输出

本地执行后能得到预期的覆盖率结果:

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)

GitHub流水线的错误日志

但在GitHub Actions里执行时,gcovr抛出了RuntimeError,gcov返回码是-11(信号退出),关键错误日志如下:

(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.
...
RuntimeError: GCOV returncode was -11 (exited by signal).

我实在搞不懂为什么本地没问题,CI里就出问题了,我还是GitHub流水线的新手,大概率是某个我没注意到的细节问题,麻烦各位帮忙看看哪里出问题了😭

备注:内容来源于stack exchange,提问作者Yohann Bénédic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 10:49:49