SimonKagstrom / kcov

Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
http://simonkagstrom.github.io/kcov/
GNU General Public License v2.0
720 stars 110 forks source link

osx: kcov hangs for rust #319

Closed julienJean99 closed 4 years ago

julienJean99 commented 4 years ago

hi,

I just spent the day trying to troubleshoot why Kcov hangs after running you can see what I tried here but here a recap

I am on:

macOS version 10.15.2 (19C57)
cargo 1.42.0-nightly (86134e766 2019-12-23)
kcov 38 install via brew

I am using this command kcov --exclude-pattern=/.cargo Project_Root/target/cov Project_Root/target/debug/$PKGNAME-*.

when it is run it creates the /cov dir and the index.html (which I suppose to tell me that everything is finished) but the program never ends and I get this on the screen running 0 tests and nothing more. I can't C-c out and so I send a segFault to stop it.

as an additional annoyance when RUSTFLAGS='-C link-dead-code' is set kcov never creat the index.html.

could it be related to #278?

SimonKagstrom commented 4 years ago

I don't think it's related to #278, in that case the program actually crashes, and that doesn't seem to be the case here.

You can add --debug=31 to enable more printouts. Sometimes it's possible to see exactly where it hangs then. Also, you could try limiting the collection a bit more with --include-pattern, if there is a problematic section which gets it to hang.

julienJean99 commented 4 years ago

thank you for the quick response. Unfortunately, I have access to this project on Tuesday and Friday so I'll get back to you then.

julienJean99 commented 4 years ago

so @SimonKagstrom I ran with --debug and at the end it print's STOPPED in state 5 i redirect to the output to a file do you want it.

julienJean99 commented 4 years ago

Hi, I'm sorry to spam a little but I fixed the hanging problem with docker. But here is the output of running kcov:

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out

so the test is filtered out and I don't know why. Note that it is not due to the binary of cargo --no-run cause when running the binary on its own here is the output:

running 1 test
test tests::test ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

since in the kcov case, the test is filtered the test never runs and is not counted towards the coverage.

here is the latest command i'm using for kcov: kcov --exclude-pattern=/usr --include-pattern=/app/src /app/target/cov /app/target/debug/PKGNAME

SimonKagstrom commented 4 years ago

Hmm... I'm not sure why kcov would filter a test out, are you sure that the parameters to the program is exactly the same in both cases?

Anyway, I'm not familiar with rust, so I might be missing something crucial here.

julienJean99 commented 4 years ago

for me, the only thing ta differs is the use of kcov but I can make more test next week by doing every step by hand and i can come back with maybe more info and the output file

SimonKagstrom commented 4 years ago

OK, thanks for the patience!

julienJean99 commented 4 years ago

ok, so I don't know what was wrong. I used a bash script I found to execute kcov but it seems like there was something wrong with it so I simplified the script by putting the hard path rather than looking for it every time.(not the prettiest but at least it works).

also, you have the output of kcov --debug=31 when it was hanging here: output.txt

thank you so much for being active and nice.

SimonKagstrom commented 4 years ago

Good to hear that you resolved it!

It's still strange that kcov should hang. Could there be multiple kcovs installed, i.e., is the one you use the hard path to the same as if you run which kcov?

julienJean99 commented 4 years ago

no the one I use the hard path is in the docker and I build it from the source of the master branch. The hanging one is the one I installed in macOS via brew install.