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 produces "geninfo: ERROR: ERROR: Could not copy file" #4517

Open
1 task done
flrl opened this issue Apr 7, 2024 · 0 comments
Open
1 task done

lcov produces "geninfo: ERROR: ERROR: Could not copy file" #4517

flrl opened this issue Apr 7, 2024 · 0 comments
Labels

Comments

@flrl
Copy link

flrl commented Apr 7, 2024

Description / Steps to reproduce the issue

Build something with --coverage enabled, and then use lcov to produce some foo.info file from its foo.gcno files

Expected behavior

Tool works, foo.info produced

Actual behavior

lcov --rc lcov_branch_coverage=1 --directory . --capture --initial -o app_base.info
Capturing coverage data from .
Found gcov version: 13.2.0
Using intermediate gcov format
Using JSON module JSON::PP
Scanning . for .gcno files ...
Found 10 graph files in .
Processing build\test-array.gcno
geninfo: ERROR: ERROR: Could not copy file C:\msys64\home\ellie\source\ships\build\test-array.gcno!

geninfo is trying to copy the original foo.gcno file to a temporary working location, but it incorrectly computes the destination path as something like "/tmp/whatever/C:\real\windows\path\foo.gcno", which then gets rejected by the copy operation (presumably because of the :), leading to the error above

The problem is in its split_filename() function. It splits the path only on '/', which means instead of correctly separating out the directory, basename, and extension, it instead produces an empty directory, the entire windows path in the basename, and the correct extension. The caller then constructs the destination path from tmp + basename + extension, and you can see the result.

The fix is trivial, this is what I have changed on my system:

--- /ucrt64/bin/geninfo.orig    2024-04-06 14:47:14.138205400 +1100
+++ /ucrt64/bin/geninfo 2024-04-06 15:17:43.820164000 +1100
@@ -1690,7 +1690,7 @@

 sub split_filename($)
 {
-       my @path_components = split('/', $_[0]);
+       my @path_components = split(/[\\\/]/, $_[0]);
        my @file_components = split('\.', pop(@path_components));
        my $extension = pop(@file_components);

With that change (splitting paths on either back- or forward-slash), it works as expected. Hopefully this is useful to someone

Verification

Windows Version

MSYS_NT-10.0-19045

Are you willing to submit a PR?

patch included

@flrl flrl added the bug label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant