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

tracing: #[instrument] macro interferes with LLVM-based instrument-coverage #2082

Open
davidbarsky opened this issue Apr 18, 2022 · 3 comments

Comments

@davidbarsky
Copy link
Member

Bug Report

Version

coverage-repro on ξ‚  master is πŸ“¦ v0.1.0 via πŸ¦€ v1.62.0-nightly
❯ cargo tree
coverage-repro v0.1.0 (/Users/dbarsky/Developer/coverage-repro)
└── tracing v0.1.34
    β”œβ”€β”€ cfg-if v1.0.0
    β”œβ”€β”€ pin-project-lite v0.2.8
    β”œβ”€β”€ tracing-attributes v0.1.20 (proc-macro)
    β”‚   β”œβ”€β”€ proc-macro2 v1.0.37
    β”‚   β”‚   └── unicode-xid v0.2.2
    β”‚   β”œβ”€β”€ quote v1.0.18
    β”‚   β”‚   └── proc-macro2 v1.0.37 (*)
    β”‚   └── syn v1.0.91
    β”‚       β”œβ”€β”€ proc-macro2 v1.0.37 (*)
    β”‚       β”œβ”€β”€ quote v1.0.18 (*)
    β”‚       └── unicode-xid v0.2.2
    └── tracing-core v0.1.26
        └── lazy_static v1.4.0

I made a reproduction in davidbarsky/tracing-coverage-reproduction. Note that to reproduce this issue, llvm-tools-preview and grcov are required. To install those tools:

rustup component add llvm-tools-preview
cargo install grcov

Platform

❯ uname -a
Darwin dbarsky-mbp 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000 arm64

❯ rustc --version
rustc 1.62.0-nightly (ec77f2524 2022-04-17)

❯ cargo --version
cargo 1.62.0-nightly (dba5baf43 2022-04-13)

❯ grcov --version
grcov 0.8.9

❯ rustup show
Default host: aarch64-apple-darwin
rustup home:  /Users/dbarsky/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin (default)
nightly-2021-11-29-aarch64-apple-darwin
nightly-aarch64-apple-darwin

active toolchain
----------------

nightly-aarch64-apple-darwin (directory override for '/Users/dbarsky/Developer/coverage-repro')
rustc 1.62.0-nightly (ec77f2524 2022-04-17)

Crates

  • tracing 0.1.32

Description

The #[instrument] macro appears to mess with the LLVM's code coverage. This might be inherent to macros that rewrite function bodies, as #[instrument] does. Here is the code coverage on a function decorated with #[instrument]:

with

...and here is a function without #[instrument]:

without

(This was reported to me by @DirectXMan12.)

@davidbarsky davidbarsky modified the milestone: tracing 0.2 Apr 18, 2022
@davidbarsky
Copy link
Member Author

I've confirmed that #[async_trait] doesn't have this issue. cargo rustc --profile=check -- -Zunpretty=expanded does show that the #[instrument] macro expands into something a bit more complex than #[async_trait].

@davidbarsky
Copy link
Member Author

This might be caused by rust-lang/rust#110486.

@davidbarsky
Copy link
Member Author

I've confirmed that this is still an issue on rustc 1.77.0-nightly (a2d9d73e6 2024-01-10).

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

No branches or pull requests

1 participant