Skip to content

cargo test then cargo tarpaulin causes BorrowMut error and linking failure #9220

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

Closed
xd009642 opened this issue Mar 1, 2021 · 4 comments · Fixed by #9229
Closed

cargo test then cargo tarpaulin causes BorrowMut error and linking failure #9220

xd009642 opened this issue Mar 1, 2021 · 4 comments · Fixed by #9229
Labels
C-bug Category: bug

Comments

@xd009642
Copy link

xd009642 commented Mar 1, 2021

So when running cargo test with default rust flags and then running cargo tarpaulin (version 0.18.0-alpha1) cargo can output the following error (it's called within tarpaulin)

error: Broken pipe (os error 32)
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at 'already borrowed: BorrowMutError', src/tools/cargo/src/cargo/util/config/mod.rs:307:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Mar 01 19:28:55.644 ERROR cargo_tarpaulin: Failed to compile tests! Error: signals: linking with `cc` failed: exit code: 1
Error: "Failed to compile tests! Error: signals: linking with `cc` failed: exit code: 1"

To recreate the error given an example project (https://github.com/Smithay/calloop) we do the following:

cargo install cargo-tarpaulin --version 0.18.0-alpha1
git clone --depth 1 https://github.com/Smithay/calloop 
cd calloop
cargo test
cargo tarpaulin

One salient note cargo tarpaulin changes the rust flags to RUSTFLAGS=" -C link-dead-code -C debuginfo=2 --cfg=tarpaulin " so I wonder if this is a case of incremental compilation going wrong?

@xd009642
Copy link
Author

xd009642 commented Mar 1, 2021

Further comment from the person who raised this with me in tarpaulin initially:

if we do the reverse (cargo clean, then cargo tarpaulin, then cargo test), then cargo test fails with a more detailed error. For example on calloop I get undefined reference to core::ptr::drop_in_place'`.

@xd009642
Copy link
Author

xd009642 commented Mar 1, 2021

Oh also my cargo version is cargo 1.50.0 (f04e7fab7 2021-02-04)

@alexcrichton
Copy link
Member

I think this should be fixed in #9229

@xd009642
Copy link
Author

xd009642 commented Mar 2, 2021

Awesome can't wait to try it out 👍

bors added a commit that referenced this issue Mar 5, 2021
Fix a `BorrowMut` error when stdout is closed

There was one location in the job queue where the shell is borrowed
twice by accident, so instead hold the same borrow over both locations.

Closes #9220
@bors bors closed this as completed in 3f2ece7 Mar 5, 2021
avrabe added a commit to avrabe/fmu-rs that referenced this issue May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants