rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.03k stars 12.79k forks source link

Error Loading Shared Libraries When Debugging Tests In VS Code #120658

Closed coder0xff closed 9 months ago

coder0xff commented 9 months ago

I'm sorry if this isn't a Rust problem. There are a lot of moving parts, but the compiler output, or at least its interaction with the other parts, seems like a possible cause, so I'm starting here. VS Code 1.86.0, rust-analyzer extension, Ubuntu 20 LTS.

The files below are a minimal reproduction. Remove the Arc::new, or even the unused use webrtc::ice_transport::ice_candidate::RTCIceCandidate and the problem disappears.

Cargo.toml

[package]
name = "deleteme"
version = "0.1.0"
edition = "2021"

[dependencies]
webrtc = "0.9.0"

src/lib.rs

use std::sync::Arc;
use webrtc::ice_transport::ice_candidate::RTCIceCandidate;

#[test]
fn test_foobar() {
    Arc::new(0);
}

Reproduction

#[test]
▶ Run Test | Debug <--------- click Debug
fn test_foobar() {
    Arc::new(async_mutex::Mutex::new(0));
}

Output

/home/coder0xff/.../deleteme/target/debug/deps/deleteme-207adc92786ad6d7: error while loading shared libraries: cannot apply additional memory protection after relocation: Cannot allocate memory
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-wuucs5ci.t2m" 1>"/tmp/Microsoft-MIEngine-Out-tbrnxfsq.4tk"

Running the test executable on the command line or within gdb works fine. The workflow of clicking "Debug" in VS Code produces the problem. I made a cursory attempt at figuring out how Microsoft-MIEngine interacted with gdb, but what I found online was beyond me.

coder0xff commented 9 months ago

I tried with nightly rust and it works ok.