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

gcovr 5.2 crashes with UnknownLineType and "Cannot open source file" #736

Closed
martinpitt opened this issue Feb 27, 2023 · 28 comments
Closed

Comments

@martinpitt
Copy link

Describe the bug
The recent Fedora gcovr 5.2 update breaks with current meson. I noticed that in my umockdev project, which started to fail its tests a month ago. E.g. in this run there are now hundreds of errors:

(WARNING) GCOV produced the following errors processing /tmp/s/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev.c.gcda:
	Cannot open source file umockdev.c
Cannot open source file ../src/umockdev.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev.c

[... lots more similar errors ...]

	(gcovr could not infer a working directory that resolved it.)
(WARNING) Unrecognized GCOV output for /tmp/s/src/libumockdev-preload.c
	  branch  2 taken -421
	  branch  1 taken -423
	  branch  1 taken -423
	  branch  0 taken -884 (fallthrough)
	This is indicative of a gcov output parse error.
	Please report this to the gcovr developers
	at <https://github.com/gcovr/gcovr/issues>.
(WARNING) Exception during parsing:
	UnknownLineType: branch  2 taken -421
(WARNING) Exception during parsing:
	UnknownLineType: branch  1 taken -423
(WARNING) Exception during parsing:
	UnknownLineType: branch  1 taken -423
(WARNING) Exception during parsing:
	UnknownLineType: branch  0 taken -884 (fallthrough)
(ERROR) Exiting because of parse errors.
	You can run gcovr with --gcov-ignore-parse-errors
	to continue anyway.
(ERROR) Trouble processing '/tmp/s/b/libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.gcda' with working directory '/tmp/s/b'.

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/gcovr/workers.py", line 78, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.11/site-packages/gcovr/gcov.py", line 337, in process_datafile
    done = run_gcov_and_process_files(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gcovr/gcov.py", line 514, in run_gcov_and_process_files
    process_gcov_data(fname, covdata, abs_filename, options)
  File "/usr/lib/python3.11/site-packages/gcovr/gcov.py", line 157, in process_gcov_data
    coverage = parse_coverage(
               ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gcovr/gcov_parser.py", line 404, in parse_coverage
    _report_lines_with_errors(lines_with_errors, context)
  File "/usr/lib/python3.11/site-packages/gcovr/gcov_parser.py", line 552, in _report_lines_with_errors
    raise errors[0]  # guaranteed to have at least one exception
    ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gcovr/gcov_parser.py", line 353, in parse_coverage
    tokenized_lines.append((_parse_line(raw_line), raw_line))
                            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gcovr/gcov_parser.py", line 836, in _parse_line
    raise UnknownLineType(line)
gcovr.gcov_parser.UnknownLineType: branch  2 taken -421

[... and more similar crashes ... ]

To Reproduce
Steps to reproduce the behavior:

sudo dnf builddep umockdev
sudo dnf install gcovr
git clone https://github.com/martinpitt/umockdev
cd umockdev
meson setup b --buildtype debug -Db_coverage=true
cd b
meson test
ninja coverage-text

Expected behavior
Coverage report should work, like with 5.1 and earlier.

Desktop (please complete the following information):

  • OS: Fedora 37 x86_64
  • GCC version gcc 12.2.1
  • GCOVR version 5.2

Additional context
I originally reported this to Fedora in https://bugzilla.redhat.com/show_bug.cgi?id=2166960 , but was asked to report it upstream as well.

@Spacetown
Copy link
Member

Duplicate of #583. This is a gcov bug and not related to gcovr.

@martinpitt
Copy link
Author

#583 does not link to a gcov (or any other external) bug report, do you have a link to track this?

It only refers to PR #701 which introduces a --gcov-ignore-negative-counters option. Does this somehow need to be specified now? (I.e. is that some "unbreak my setup" option?) Thanks!

@Spacetown
Copy link
Member

In the linked issue this bug of gcov was discussed and the other issue is our workaround to ignore this bug. The workaround is only available on mater and will be released soon.

@martinpitt
Copy link
Author

For the record, this is still broken with gcovr 6.0, see https://bugzilla.redhat.com/show_bug.cgi?id=2166960#c7

@martinpitt
Copy link
Author

And as for the workaround: taking the gcovr call that meson produces and appending:

❱❱❱ gcovr --gcov-ignore-negative-counters -r /var/home/martin/upstream/umockdev /var/home/martin/upstream/umockdev/b -e /var/home/martin/upstream/umockdev/subprojects -o /var/home/martin/upstream/umockdev/b/meson-logs/coverage.txt 
usage: gcovr [options] [search_paths...]
gcovr: error: unrecognized arguments: --gcov-ignore-negative-counters

@Spacetown
Copy link
Member

Oh, in the PR comment the option was wrong. Please use --gcov-ignore-parse-errors=negative_hits.warn or
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file. I'll update the PR description.

@martinpitt
Copy link
Author

I tried both options, makes no difference:

❱❱❱ gcovr --gcov-ignore-parse-errors=negative_hits.warn -r /var/home/martin/upstream/umockdev /var/home/martin/upstream/umockdev/b -e /var/home/martin/upstream/umockdev/subprojects -o /var/home/martin/upstream/umockdev/b/meson-logs/coverage.txt 
(ERROR) Trouble processing '/var/home/martin/upstream/umockdev/b/umockdev-record.p/meson-generated_src_umockdev-ioctl.c.gcda' with working directory '/var/home'.
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 informations.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/gcovr/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 323, in process_datafile
    done = run_gcov_and_process_files(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 536, in run_gcov_and_process_files
    out, err = gcov_cmd.run_with_args(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 519, in run_with_args
    raise RuntimeError(f"GCOV returncode was {gcov_process.returncode}.")
RuntimeError: GCOV returncode was 6.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/gcovr/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 323, in process_datafile
    done = run_gcov_and_process_files(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 536, in run_gcov_and_process_files
    out, err = gcov_cmd.run_with_args(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 519, in run_with_args
    raise RuntimeError(f"GCOV returncode was {gcov_process.returncode}.")
RuntimeError: GCOV returncode was 6.

@Spacetown
Copy link
Member

It makes a difference. The option is accepted but GCOV itself exits with 6. This is becuase the tool is executed in /var/home which is write protected. Can you change into /var/home/martin/upstream/umockdev and remove -r /var/home/martin/upstream/umockdev from the command line arguments?

@martinpitt
Copy link
Author

Ack, with cd .. I changed from the meson build directory b/ to the source tree root.

❱❱❱ gcovr b -e subprojects -o b/meson-logs/coverage.txt
(ERROR) Trouble processing '/var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda' with working directory '/var/home'.
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 informations.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/gcovr/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 323, in process_datafile
    done = run_gcov_and_process_files(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 536, in run_gcov_and_process_files
    out, err = gcov_cmd.run_with_args(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 519, in run_with_args
    raise RuntimeError(f"GCOV returncode was {gcov_process.returncode}.")
RuntimeError: GCOV returncode was 6.

and with the new option it looks exactly the same:

gcovr --gcov-ignore-parse-errors=negative_hits.warn b -e subprojects -o b/meson-logs/coverage.txt
(ERROR) Trouble processing '/var/home/martin/upstream/umockdev/b/umockdev-record.p/meson-generated_src_umockdev-record.c.gcda' with working directory '/var/home'.
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 informations.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/gcovr/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 323, in process_datafile
    done = run_gcov_and_process_files(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 536, in run_gcov_and_process_files
    out, err = gcov_cmd.run_with_args(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gcovr/gcov.py", line 519, in run_with_args
    raise RuntimeError(f"GCOV returncode was {gcov_process.returncode}.")
RuntimeError: GCOV returncode was 6.

Why would the tool run in /var/home/? That can't be written to of course (/var/home/martin/ can), but I don't see that in any of the error messages?

(Note: I don't know what I am doing here -- meson is calling all of this behind the scenes normally)

@martinpitt
Copy link
Author

martinpitt commented Nov 28, 2023

Ah, with --verbose I indeed see:

❱❱❱ gcovr --verbose --gcov-ignore-parse-errors=negative_hits.warn b -e subprojects -o b/meson-logs/coverage.txt
[...]
DEBUG) Finding source file corresponding to a gcov data file
  gcov_fname   /var/home/martin/upstream/umockdev/b/utils.c##a901a425842679d44b61318bd3f79334.gcov
  currdir      /var/home/martin/upstream/umockdev
  root         /var/home/martin/upstream/umockdev
  starting_dir /var/home/martin/upstream/umockdev
  obj_dir      None
  gcda_fname   /var/home/martin/upstream/umockdev/b/libumockdev.so.0.3.0.p/src_utils.c.gcda
  --> fname    /var/home/martin/upstream/umockdev/b/../src/utils.c
(DEBUG) Parsing coverage data for file /var/home/martin/upstream/umockdev/b/../src/utils.c
(DEBUG) Processing file: /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda
(DEBUG) Running gcov: 'gcov /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p' in '/var/home/martin/upstream/umockdev'
(DEBUG) Running gcov: 'gcov /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p' in '/var/home/martin/upstream/umockdev/b/umockdev-run.p'
(DEBUG) Running gcov: 'gcov /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p' in '/var/home/martin/upstream/umockdev/b'
(DEBUG) Running gcov: 'gcov /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p' in '/var/home/martin/upstream/umockdev'
(DEBUG) Running gcov: 'gcov /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p' in '/var/home/martin/upstream'
(DEBUG) Running gcov: 'gcov /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p' in '/var/home/martin'
(DEBUG) Running gcov: 'gcov /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p' in '/var/home'
(ERROR) Trouble processing '/var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda' with working directory '/var/home'.
[...]

Why would it do that!?

@Spacetown
Copy link
Member

Because files are not found or can't be written by gov. Can you check the main branch?

@martinpitt
Copy link
Author

It even crashes that way with just gcovr b.

I experimented a bit with --object-directory b/ or --object-directory pwd/b/, and that changes the error, but I couldn't make it work.

@martinpitt
Copy link
Author

Sure! I did sudo rpm -e gcovr and sudo pip install git+https://github.com/gcovr/gcovr.git, and that looks quite a bit different, although it seems to be the same root cause. With the original meson command line:

❱❱ /usr/local/bin/gcovr -r /var/home/martin/upstream/umockdev /var/home/martin/upstream/umockdev/b -e /var/home/martin/upstream/umockdev/subprojects  -o /var/home/martin/upstream/umockdev/b/meson-logs/coverage.txt
(INFO) Reading coverage data...
(ERROR) GCOV produced the following errors processing /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda:
	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b/umockdev-run.p:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b:
Cannot open source file umockdev-run.c

	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /var:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 450, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda:
	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b/umockdev-run.p:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b:
Cannot open source file umockdev-run.c

	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /var:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 450, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda:
	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b/umockdev-run.p:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b:
Cannot open source file umockdev-run.c

	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /var:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) Error occurred while reading reports:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/gcovr/__main__.py", line 365, in main
    covdata: CovData = gcovr_formats.read_reports(options)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/__init__.py", line 47, in read_reports
    covdata = GcovHandler(options).read_report()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/__init__.py", line 200, in read_report
    return read_report(self.options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 79, in read_report
    with Workers(
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 173, in __exit__
    self.wait()
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 164, in wait
    raise self.exceptions[0][1]
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 86, in read_report
    contexts = pool.wait()
               ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 164, in wait
    raise self.exceptions[0][1]
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 80, in worker
    work(*args, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 450, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda:
	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b/umockdev-run.p:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b:
Cannot open source file umockdev-run.c

	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /var:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.

GCOV produced the following errors processing /var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda:
	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b/umockdev-run.p:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream/umockdev/b:
Cannot open source file umockdev-run.c

	In directory /var/home/martin/upstream/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin/upstream:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home/martin:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

	In directory /var/home:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /var:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	In directory /:
Could not open output file 'umockdev-run.c##3fa2181c4ff1ac3bda12de566e90ecb6.gcov'
Could not open output file 'umockdev-run.vala##d50b8c57f19d2e4bde91bbc3399142d6.gcov'
Could not open output file 'gstrfuncs.h##004670cf93ce5cac57378ccc9807488a.gcov'
Could not open output file 'umockdev-run.c##41d42cca07040dbeca7981df944868ae.gcov'

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.

When I add the suggested --gcov-ignore-errors=no_working_dir_found, I get the originally reported error "Got negative hit value in gcov ..". With an additional --gcov-ignore-parse-errors=negative_hits.warn_once_per_file it finally succeeds and writes meson-logs/coverage.txt.

@martinpitt
Copy link
Author

	In directory /var/home/martin/upstream/umockdev/b/umockdev-run.p:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala

FTR: this one gets close, but the source file is in ./b/umockdev-run.p/src/umockdev-run.c.

@Spacetown
Copy link
Member

In which directory was the compiler executed to build the object file? Can you try to run gcov on your own in this directory?

@Spacetown Spacetown reopened this Nov 28, 2023
@martinpitt
Copy link
Author

Not sure if I understood your question correctly: But the reproducer (as in the issue description) runs in the b/ (build tree) subdirectory of the source code checkout root (/home/martin/upstream/umockdev/ in my case). Running strace -fvvs1024 -e execve -o /tmp/t meson build in the b/ subdir confirms that both valac and cc are run in PWD=/var/home/martin/upstream/umockdev/b.

@Spacetown
Copy link
Member

Can you execute the gcov command from the verbose output in this working directory and check the output?

@martinpitt
Copy link
Author

I'm not 100% sure that you meant this, hence the full reproducer (in an F39 container or toolbox) from scratch:

sudo dnf builddep -y umockdev
sudo dnf install -y gcovr
git clone https://github.com/martinpitt/umockdev
cd umockdev
meson setup b --buildtype debug -Db_coverage=true
cd b
meson test
strace -fvvs1024 -e execve -o /tmp/trace ninja coverage-text

fails with said

(ERROR) Trouble processing '/var/home/martin/upstream/umockdev/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev-spi.c.gcda' with working directory '/var/home'.

and /tmp/trace shows a bunch of successful calls, like

[pid 57002] execve("/usr/bin/gcov", ["gcov", "/var/home/martin/upstream/umockdev/b/libumockdev-preload.so.0.0.0.p/src_utils.c.gcda", "--branch-counts", "--branch-probabilities", "--demangled-names", "--hash-filenames", "--object-directory", "/var/home/martin/upstream/umockdev/b/libumockdev-preload.so.0.0.0.p"], ["SHELL=/bin/bash", "PWD=/var/home/martin/upstream/umockdev/b", ...]) = 0
[pid 57002] +++ exited with 0 +++

and the failed call which exits with 6:

[pid 57010] execve("/usr/bin/gcov", ["gcov", "/var/home/martin/upstream/umockdev/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev.c.gcda", "--branch-counts", "--branch-probabilities", "--demangled-names", "--hash-filenames", "--object-directory", "/var/home/martin/upstream/umockdev/b/libumockdev.so.0.3.0.p"], ["PWD=/var/home/martin/upstream/umockdev/b", ...]) = 0
57010 +++ exited with 6 +++

calling this manually fails differently, though:

$ gcov /var/home/martin/upstream/umockdev/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev.c.gcda --branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory /var/home/martin/upstream/umockdev/b/umockdev-run.p
/var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev.c.gcno:cannot open notes file
/var/home/martin/upstream/umockdev/b/umockdev-run.p/meson-generated_src_umockdev.c.gcda:cannot open data file, assuming not executed
No executable lines

So, TBH I'm lost here..

@martinpitt
Copy link
Author

The reproducer still fails, but oh well -- for now I can cling to only running gcovr on Ubuntu 22.04 LTS (gcovr version 5.0).

@Spacetown
Copy link
Member

Can you check the main branch?

@Spacetown Spacetown reopened this Feb 23, 2024
@Spacetown
Copy link
Member

@martinpitt Any updates with the latest version?

@martinpitt
Copy link
Author

martinpitt commented Mar 6, 2024

Sorry about the delay!

Running this again from thin air, in

podman run -it --rm registry.fedoraproject.org/fedora

and inside:

dnf install -y 'dnf-command(builddep)'
dnf builddep -y umockdev
dnf install -y git-core python3-pip
pip install git+https://github.com/gcovr/gcovr.git

# run build/tests as user
su -s /bin/bash nobody
cd /tmp

git clone https://github.com/martinpitt/umockdev
cd umockdev
meson setup b --buildtype debug -Db_coverage=true
cd b
# this is gonna fail with current main due to some unexpected SELinux context, but ignore -- I'll fix that separately
meson test
ninja coverage-text

that still fails with

(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/umockdev-record.p/meson-generated_src_umockdev-ioctl.c.gcda:
	In directory /tmp/umockdev:
Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file umockdev-record.p/src/umockdev-ioctl.c
[..]
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.

and lots of similar errors. I again tried to run it directly with teh suggested option:

gcovr --gcov-ignore-errors=no_working_dir_found -r /tmp/umockdev /tmp/umockdev/b -e /tmp/umockdev/subprojects -o /tmp/umockdev/b/meson-logs/coverage.txt

but that just fails again with the same "no working dir" error:

``` (INFO) Reading coverage data... (ERROR) GCOV produced the following errors processing /tmp/umockdev/b/umockdev-record.p/meson-generated_src_umockdev-record.c.gcda: In directory /tmp/umockdev: Cannot open source file umockdev-record.c Cannot open source file ../src/umockdev-record.vala Cannot open source file glib-2.0.vapi Cannot open source file umockdev-record.p/src/umockdev-record.c
In directory /tmp/umockdev/b/umockdev-record.p:

Cannot open source file umockdev-record.c
Cannot open source file ../src/umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-record.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-record.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

Cannot open source file umockdev-record.c
Cannot open source file ../src/umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-record.c

In directory /tmp:

Cannot open source file umockdev-record.c
Cannot open source file ../src/umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-record.c

In directory /:

Cannot open source file umockdev-record.c
Cannot open source file ../src/umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-record.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(WARNING) Unrecognized GCOV output for /tmp/umockdev/src/libumockdev-preload.c
branch 2 taken -315
branch 1 taken -317
branch 1 taken -317
branch 0 taken -672 (fallthrough)
This is indicative of a gcov output parse error.
Please report this to the gcovr developers
at https://github.com/gcovr/gcovr/issues.
(WARNING) Exception during parsing:
NegativeHits: Got negative hit value in gcov line 'branch 2 taken -315' caused by a bug in gcov tool, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080. Use option --gcov-ignore-parse-errors with a value of negative_hits.warn, or negative_hits.warn_once_per_file.
(WARNING) Exception during parsing:
NegativeHits: Got negative hit value in gcov line 'branch 1 taken -317' caused by a bug in gcov tool, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080. Use option --gcov-ignore-parse-errors with a value of negative_hits.warn, or negative_hits.warn_once_per_file.
(WARNING) Exception during parsing:
NegativeHits: Got negative hit value in gcov line 'branch 1 taken -317' caused by a bug in gcov tool, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080. Use option --gcov-ignore-parse-errors with a value of negative_hits.warn, or negative_hits.warn_once_per_file.
(WARNING) Exception during parsing:
NegativeHits: Got negative hit value in gcov line 'branch 0 taken -672 (fallthrough)' caused by a bug in gcov tool, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080. Use option --gcov-ignore-parse-errors with a value of negative_hits.warn, or negative_hits.warn_once_per_file.
(ERROR) Exiting because of parse errors.
You can run gcovr with --gcov-ignore-parse-errors
to continue anyway.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.gcda:
In directory /tmp/umockdev:
Cannot open source file ../src/libumockdev-preload.c

In directory /tmp/umockdev/b/libumockdev-preload.so.0.0.0.p:

Cannot open source file ../src/libumockdev-preload.c

Trouble processing '/tmp/umockdev/b/libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.gcda' with working directory '/tmp/umockdev/b'.

Stdout of gcov was >>File '/usr/include/unistd.h'
Lines executed:77.78% of 9
Branches executed:77.78% of 18
Taken at least once:77.78% of 18
No calls
Creating 'unistd.h##a22e9d2ab9e4b77715d83ce7f813ed48.gcov'

File '../src/libumockdev-preload.c'
Lines executed:77.24% of 725
Branches executed:75.12% of 1069
Taken at least once:53.04% of 1069
Calls executed:48.85% of 868
Creating 'libumockdev-preload.c##43283a376f43599068a1578f557d7529.gcov'

File '/usr/include/sys/ioctl.h'
Lines executed:100.00% of 1
Branches executed:100.00% of 2
Taken at least once:50.00% of 2
No calls
Creating 'ioctl.h##dcaaf2275b38f818358bd9384bc2c8a9.gcov'

File '/usr/include/stdio.h'
Lines executed:100.00% of 6
Branches executed:100.00% of 12
Taken at least once:100.00% of 12
No calls
Creating 'stdio.h##79ef0634ae8f8ca929453be1ddd8933f.gcov'

File '/usr/include/sys/socket.h'
Lines executed:100.00% of 6
Branches executed:100.00% of 12
Taken at least once:100.00% of 12
No calls
Creating 'socket.h##7734a1305a0af7b289bce8306dd574e2.gcov'

File '/usr/include/stdlib.h'
Lines executed:100.00% of 2
Branches executed:100.00% of 4
Taken at least once:100.00% of 4
No calls
Creating 'stdlib.h##028095b41857dcdeb715926b63fafaef.gcov'

File '/usr/include/sys/inotify.h'
Lines executed:0.00% of 1
Branches executed:0.00% of 2
Taken at least once:0.00% of 2
No calls
Creating 'inotify.h##974d225476f128bd5adcdfe2446c74fc.gcov'

File '/usr/include/fcntl.h'
Lines executed:100.00% of 4
Branches executed:100.00% of 8
Taken at least once:87.50% of 8
No calls
Creating 'fcntl.h##1a2302e27447f2ff7cafdac41b8bba20.gcov'

File '/usr/include/sys/statfs.h'
Lines executed:100.00% of 4
Branches executed:100.00% of 8
Taken at least once:87.50% of 8
No calls
Creating 'statfs.h##a950ef32633a61ee2832bf92a8db7ac6.gcov'

File '/usr/include/bits/statx-generic.h'
Lines executed:100.00% of 1
Branches executed:100.00% of 2
Taken at least once:100.00% of 2
No calls
Creating 'statx-generic.h##4f3aa90108df644496b29f869c1cc32d.gcov'

File '/usr/include/sys/xattr.h'
Lines executed:50.00% of 2
Branches executed:50.00% of 4
Taken at least once:50.00% of 4
No calls
Creating 'xattr.h##cd7be130bcd201433950c5c79bcb0691.gcov'

File '/usr/include/sys/stat.h'
Lines executed:75.00% of 8
Branches executed:75.00% of 16
Taken at least once:75.00% of 16
No calls
Creating 'stat.h##6e752c1756cbd9c4dccab9261559b232.gcov'

File '/usr/include/dirent.h'
Lines executed:100.00% of 1
Branches executed:100.00% of 2
Taken at least once:100.00% of 2
No calls
Creating 'dirent.h##ee35345deead177559be16e677f4eeff.gcov'

Lines executed:77.79% of 770
<< End of stdout
Stderr of gcov was >><< End of stderr
Exception was >>Got negative hit value in gcov line 'branch 2 taken -315' caused by a bug in gcov tool, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080. Use option --gcov-ignore-parse-errors with a value of negative_hits.warn, or negative_hits.warn_once_per_file.<< End of stderr
Current processed gcov file was '/tmp/umockdev/b/libumockdev-preload.c##43283a376f43599068a1578f557d7529.gcov'.
Use option --verbose to get extended information.
In directory /tmp/umockdev:
Cannot open source file ../src/libumockdev-preload.c

In directory /tmp:

Cannot open source file ../src/libumockdev-preload.c

In directory /:

Cannot open source file ../src/libumockdev-preload.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/umockdev-record.p/meson-generated_src_umockdev-spi.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-spi.c

In directory /tmp/umockdev/b/umockdev-record.p:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-spi.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-spi.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-spi.c

In directory /tmp:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-spi.c

In directory /:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-spi.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/libumockdev-utils.a.p/meson-generated_src_umockdev-utils.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-utils.c
Cannot open source file ../src/umockdev-utils.vala
Cannot open source file libumockdev-utils.a.p/src/umockdev-utils.c

In directory /tmp/umockdev/b/libumockdev-utils.a.p:

Cannot open source file umockdev-utils.c
Cannot open source file ../src/umockdev-utils.vala
Cannot open source file libumockdev-utils.a.p/src/umockdev-utils.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-utils.c

In directory /tmp/umockdev:

Cannot open source file umockdev-utils.c
Cannot open source file ../src/umockdev-utils.vala
Cannot open source file libumockdev-utils.a.p/src/umockdev-utils.c

In directory /tmp:

Cannot open source file umockdev-utils.c
Cannot open source file ../src/umockdev-utils.vala
Cannot open source file libumockdev-utils.a.p/src/umockdev-utils.c

In directory /:

Cannot open source file umockdev-utils.c
Cannot open source file ../src/umockdev-utils.vala
Cannot open source file libumockdev-utils.a.p/src/umockdev-utils.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/test-umockdev-record.p/meson-generated_tests_test-umockdev-record.c.gcda:
In directory /tmp/umockdev:
Cannot open source file test-umockdev-record.c
Cannot open source file ../tests/test-umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-record.p/tests/test-umockdev-record.c

In directory /tmp/umockdev/b/test-umockdev-record.p:

Cannot open source file test-umockdev-record.c
Cannot open source file ../tests/test-umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-record.p/tests/test-umockdev-record.c

In directory /tmp/umockdev/b:

Cannot open source file test-umockdev-record.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

Cannot open source file test-umockdev-record.c
Cannot open source file ../tests/test-umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-record.p/tests/test-umockdev-record.c

In directory /tmp:

Cannot open source file test-umockdev-record.c
Cannot open source file ../tests/test-umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-record.p/tests/test-umockdev-record.c

In directory /:

Cannot open source file test-umockdev-record.c
Cannot open source file ../tests/test-umockdev-record.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-record.p/tests/test-umockdev-record.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev-ioctl.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-ioctl.c

In directory /tmp/umockdev/b/libumockdev.so.0.3.0.p:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-ioctl.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-ioctl.c

In directory /tmp/umockdev:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-ioctl.c

In directory /tmp:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-ioctl.c

In directory /:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-ioctl.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.gcno:
In directory /tmp/umockdev:
b/test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-vala.c
Cannot open source file ../tests/test-umockdev-vala.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-vala.p/tests/test-umockdev-vala.c

In directory /tmp/umockdev/b/test-umockdev-vala.p:

./meson-generated_tests_test-umockdev-vala.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-vala.c
Cannot open source file ../tests/test-umockdev-vala.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-vala.p/tests/test-umockdev-vala.c

In directory /tmp/umockdev/b:

test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-vala.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

b/test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-vala.c
Cannot open source file ../tests/test-umockdev-vala.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-vala.p/tests/test-umockdev-vala.c

In directory /tmp:

umockdev/b/test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-vala.c
Cannot open source file ../tests/test-umockdev-vala.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-vala.p/tests/test-umockdev-vala.c

In directory /:

tmp/umockdev/b/test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-vala.c
Cannot open source file ../tests/test-umockdev-vala.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-vala.p/tests/test-umockdev-vala.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev-pcap.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-pcap.c

In directory /tmp/umockdev/b/libumockdev.so.0.3.0.p:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-pcap.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-pcap.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-pcap.c

In directory /tmp:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-pcap.c

In directory /:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-pcap.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/umockdev-record.p/meson-generated_src_umockdev-ioctl.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file umockdev-record.p/src/umockdev-ioctl.c

In directory /tmp/umockdev/b/umockdev-record.p:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file umockdev-record.p/src/umockdev-ioctl.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-ioctl.c

In directory /tmp/umockdev:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file umockdev-record.p/src/umockdev-ioctl.c

In directory /tmp:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file umockdev-record.p/src/umockdev-ioctl.c

In directory /:

Cannot open source file umockdev-ioctl.c
Cannot open source file ../src/umockdev-ioctl.vala
Cannot open source file umockdev-record.p/src/umockdev-ioctl.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/umockdev-record.p/meson-generated_src_umockdev-pcap.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-pcap.c

In directory /tmp/umockdev/b/umockdev-record.p:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-pcap.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-pcap.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-pcap.c

In directory /tmp:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-pcap.c

In directory /:

Cannot open source file umockdev-pcap.c
Cannot open source file ../src/umockdev-pcap.vala
Cannot open source file glib-2.0.vapi
Cannot open source file umockdev-record.p/src/umockdev-pcap.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/umockdev-run.p/meson-generated_src_umockdev-run.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

In directory /tmp/umockdev/b/umockdev-run.p:

Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-run.c

In directory /tmp/umockdev:

Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

In directory /tmp:

Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

In directory /:

Cannot open source file umockdev-run.c
Cannot open source file ../src/umockdev-run.vala
Cannot open source file umockdev-run.p/src/umockdev-run.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev.c
Cannot open source file ../src/umockdev.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev.c

In directory /tmp/umockdev/b/libumockdev.so.0.3.0.p:

Cannot open source file umockdev.c
Cannot open source file ../src/umockdev.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

Cannot open source file umockdev.c
Cannot open source file ../src/umockdev.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev.c

In directory /tmp:

Cannot open source file umockdev.c
Cannot open source file ../src/umockdev.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev.c

In directory /:

Cannot open source file umockdev.c
Cannot open source file ../src/umockdev.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/test-umockdev-run.p/meson-generated_tests_test-umockdev-run.c.gcno:
In directory /tmp/umockdev:
b/test-umockdev-run.p/meson-generated_tests_test-umockdev-run.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-run.c
Cannot open source file ../tests/test-umockdev-run.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-run.p/tests/test-umockdev-run.c

In directory /tmp/umockdev/b/test-umockdev-run.p:

./meson-generated_tests_test-umockdev-run.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-run.c
Cannot open source file ../tests/test-umockdev-run.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-run.p/tests/test-umockdev-run.c

In directory /tmp/umockdev/b:

test-umockdev-run.p/meson-generated_tests_test-umockdev-run.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-run.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

b/test-umockdev-run.p/meson-generated_tests_test-umockdev-run.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-run.c
Cannot open source file ../tests/test-umockdev-run.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-run.p/tests/test-umockdev-run.c

In directory /tmp:

umockdev/b/test-umockdev-run.p/meson-generated_tests_test-umockdev-run.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-run.c
Cannot open source file ../tests/test-umockdev-run.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-run.p/tests/test-umockdev-run.c

In directory /:

tmp/umockdev/b/test-umockdev-run.p/meson-generated_tests_test-umockdev-run.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-run.c
Cannot open source file ../tests/test-umockdev-run.vala
Cannot open source file glib-2.0.vapi
Cannot open source file test-umockdev-run.p/tests/test-umockdev-run.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) GCOV produced the following errors processing /tmp/umockdev/b/libumockdev.so.0.3.0.p/meson-generated_src_umockdev-spi.c.gcda:
In directory /tmp/umockdev:
Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-spi.c

In directory /tmp/umockdev/b/libumockdev.so.0.3.0.p:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-spi.c

In directory /tmp/umockdev/b:

Cannot open source file umockdev-spi.c
Cannot open source file glib-2.0.vapi

In directory /tmp/umockdev:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-spi.c

In directory /tmp:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-spi.c

In directory /:

Cannot open source file umockdev-spi.c
Cannot open source file ../src/umockdev-spi.vala
Cannot open source file glib-2.0.vapi
Cannot open source file libumockdev.so.0.3.0.p/src/umockdev-spi.c

(gcovr could not infer a working directory that resolved it.)

To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(INFO) Writing coverage report...

</details>

@Spacetown
Copy link
Member

I can reproduce it but I don't get how meson is working. I found out that the compiler is executed in the directory /tmp/umockdev/b. But I'm wondering why gcc is referencing this files without path:

	In directory /tmp/umockdev/b:
test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.gcda:cannot open data file, assuming not executed
Cannot open source file test-umockdev-vala.c
Cannot open source file glib-2.0.vapi

The file test-umockdev-vala.c is in directory /tmp/umockdev/b/test-umockdev-vala.p/tests.

In my opinion the file created by the compiler is wrong, the source file is given as test-umockdev-vala.p/tests/test-umockdev-vala.c but the path is stripped away.

Can you add the option -fprofile-abs-path to the cc call?

@martinpitt
Copy link
Author

I tried that:

diff --git meson.build meson.build
index f77f7ea..a263aae 100644
--- meson.build
+++ meson.build
@@ -8,6 +8,7 @@ lib_version = '0.3.0'
 
 add_project_arguments(
   '-std=gnu11',
+  '-fprofile-abs-path',
   '-Werror=missing-prototypes',
   '-Werror=strict-prototypes',
   '-Werror=nested-externs',

and with meson compile -v I see that it does get applied, this CLI contains -fprofile-abs-path:

[52/55] ccache cc -Itest-umockdev-vala.p -I. -I.. -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gudev-1.0 -fdiagnostics-color=always --coverage -D_FILE_OFFSET_BITS=64 -w -O0 -g -std=gnu11 -fprofile-abs-path -Werror=missing-prototypes -Werror=strict-prototypes -Werror=nested-externs -Werror=pointer-arith -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=return-type -Werror=uninitialized -Wcast-align -Wno-error=pragmas -Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types -Wno-error=pointer-sign -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-label -Wno-unused-value -Wno-unused-variable -pthread -MD -MQ test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.o -MF test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.o.d -o test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.o -c test-umockdev-vala.p/tests/test-umockdev-vala.c

but it doesn't make a difference 😢 , it still fails the same way.

@Spacetown
Copy link
Member

I see here that ccache is used. Can you try to build and run without using ccache?

@martinpitt
Copy link
Author

Sorry, I thought I sent that reply last week, but apparently it didn't come through -- rm -rf ~/.cache/ccache/ makes no difference.

@Spacetown
Copy link
Member

This seems to be a gcov bug which can't be solved by gcovr. Even if the gcov tool is called in the correct directory the wrong path is written to the result file.

Can you check the content of test-umockdev-vala.p/meson-generated_tests_test-umockdev-vala.c.o.d how the paths are inside this file?

@Spacetown
Copy link
Member

Closing because of no response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants