Skip to content

Link-dead-code and -Z instrument-coverage causes segfault and no coverage on Windows #87649

Closed
@xd009642

Description

@xd009642

With the following RUSTFLAGS=" -C link-dead-code -C debuginfo=2 --cfg=tarpaulin -Z instrument-coverage " and nightly-x86_64-pc-windows-msvc unchanged - rustc 1.56.0-nightly (4927238 2021-07-29) and this test:

//lib.rs
pub mod unused; 

pub fn branch_test_one(x: i32) -> i32 {
    if x > 5 {
        10
    } else {
        5
    }
}

#[cfg(test)]
mod tests {
    use branch_test_one;
    #[test]
    fn bad_test() {
        branch_test_one(2);
    }
}

unused.rs contains just a single function that's never used:

//unused.rs
pub fn hello() {
    println!("Hello world");
    println!("I'm never tested");
}

I expected to see to see it exit fine and the profraw file generated and the test exit successfully. Instead an empty profraw file is generated and the test segfaults. I don't know if this is connected to #77553 @richkadel

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions