nextest-rs / nextest

A next-generation test runner for Rust.
https://nexte.st
Apache License 2.0
2.11k stars 92 forks source link

loading shared libraries error #82

Closed chienguo closed 2 years ago

chienguo commented 2 years ago

I used tcmalloc in my one project, but when I tried to use nextest, it complained about cannot open shared object file:

/home/chien/Developments/Rust/lock-free/target/debug/deps/lock_free-502d561706e2470e: error while loading shared libraries: libtcmalloc.so.4: cannot open shared object file: No such file or directory
Error:
   0: error building test list
   1: running ''/home/chien/Developments/Rust/lock-free/target/debug/deps/lock_free-502d561706e2470e --list --format --terse'' failed
   2: command ["/home/chien/Developments/Rust/lock-free/target/debug/deps/lock_free-502d561706e2470e", "--list", "--format", "terse"] exited with code 127

Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

but it works fine when i use cargo test. here is my environment information:

rustc  ver: 1.60.0-nightly
rustup ver: 1.24.3
cargo  ver: 1.60.0-nightly
os: Debian GNU/Linux 11 (bullseye)
kernel: 5.10.0-11-amd64
sunshowers commented 2 years ago

Thanks for the report! how are you using tcmalloc?

chienguo commented 2 years ago

I just follow the steps from the tcmalloc trate doc like this add this line in Cargo.toml:

tcmalloc = { version = "0.3.0", features = ["bundled"] }

and in lib.rs:

#[global_allocator]
static GLOBAL: tcmalloc::TCMalloc = tcmalloc::TCMalloc;
sunshowers commented 2 years ago

Thanks!

This is a little tricky to support. It looks like we can grab the linked_libs and linked_paths values from the build-script-executed event, and add them accordingly to LD_LIBRARY_PATH. However, we still need to check whether cargo test adds them to all invocations or just the ones that transitively depend on (eg) tcmalloc.

I'm not going to work on this for the next 2-3 weeks at least, but if someone would like to, please go ahead!

{"reason":"build-script-executed","package_id":"tcmalloc-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)","linked_libs":["static=tcmalloc"],"linked_paths":["native=/home/rain/dev/tmp/tcmalloc-test/target/debug/build/tcmalloc-sys-367b2d4b4b14a39c/out/build/.libs"],"cfgs":[],"env":[],"out_dir":"/home/rain/dev/tmp/tcmalloc-test/target/debug/build/tcmalloc-sys-367b2d4b4b14a39c/out"}
chamons commented 2 years ago

I have a project not using tcmalloc (to my knowledge) which is also hitting this.

Here is the relevant section of my cargo.toml:

https://gist.github.com/chamons/131d4d223b7f89fd8c436a18895a7f3d

Here is my output:

    Finished test [unoptimized + debuginfo] target(s) in 0.13s
Error: 
   0: error building test list
   1: running ''PATH/target/debug/deps/integration-1e38b67d0761f368 --list --format terse'' failed
   2: command ["PATH/target/debug/deps/integration-1e38b67d0761f368", "--list", "--format", "terse"] exited with code <signal 9>

Deleting integration-1e38b67d0761f368 and running test again seems to work around it, but it makes using nextest pretty unreliable as often as I'm hitting it.

sunshowers commented 2 years ago

Working on this now!

sunshowers commented 2 years ago

Fix for this will go out in the next release, some time this week.