taiki-e / cargo-llvm-cov

Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Apache License 2.0
933 stars 57 forks source link

No coverage from killed subprocesses #235

Open wucke13 opened 1 year ago

wucke13 commented 1 year ago

I have the following setup:

With this setup, zero coverage is reported. What could be the culprit, and how can I get cargo-llvm-cov to report some coverage out of this setup?

Edit: It turns out I get a sensible coverage report if the process exit()s instead of being killed. Is there any way around this?

taiki-e commented 1 year ago

This is a compiler bug (or limitation). (Also, even exit() is not handled well by compilers on some platforms: https://github.com/rust-lang/rust/issues/77553)

wucke13 commented 1 year ago

@taiki-e Thank your for the quick response. A note though: https://github.com/rust-lang/rust/issues/77553 mentions something akin

This bug does not occur on Linux or MacOS.

However, I see this on a Linux machine.

taiki-e commented 1 year ago

https://github.com/rust-lang/rust/issues/77553 is about std::process::exit(), your issue is probably about SIGKILL.

std::process::exit() works on linux and macos, but SIGKILL probably does not work on any platform.

KaareKristensen commented 1 year ago

If exit is only used in the main function a quick and dirty way of circumventing this issue is to let main return an std::process::ExitCode instead.

taiki-e commented 1 year ago

I have found an option that potentially handles this well (https://github.com/taiki-e/cargo-llvm-cov/pull/280), but something seems to be missing to actually make it work.