Closed rpoyner-tri closed 2 years ago
Good analysis of the problem! I think your patch is correct, so feel free to submit a pull request. There are some automated CI tests in tests/, so I think they would find a regression (which is probably unlikely here). You could also add a Python test there (i.e., a symlink to another file) which would trigger this problem, but the testsuite needs to be run like in .github/workflows/ci-run-tests.sh , so somewhat error-prone :-)
Anyway, thanks for both analysing and providing a fix for the problem!
Thanks for providing a fabulous tool; we use it all the time.
While trying to integrate
kcov
into our builds to collect python coverage, I noticed it can mis-parse command lines where the coverage target executable is a symbolic link.For example, given a simple directory containing
echo.py
(it just prints sys.argv) and a symlink to it calledlink_echo.py
, these command lines appear to work correctly:This one, however, confuses
kcov
since it tries to interpret the "flag" argument:From a quick debug session with
kcov
master, it looks like the first thing that goes wrong is thatpeek_file()
refuses to read bytes out of the symlink file, and things go downhill from there.I was able to improve things a bit with a one-line patch:
Of course, I didn't consider any cases where this change might break things, nor did I write any tests. I'm hoping you can reproduce the issue and give it a proper treatment when you have time.
I originally discovered the problem in
kcov
38, and did my experiments and patching on very recent master.