rust-lang / rust

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

Unable to link use of hyper_util with -Zsanitizer=address on msvc #124390

Open russelltg opened 6 months ago

russelltg commented 6 months ago

I tried this code:

// Cargo.toml
// [package]
// name = "conflicting_weak_bug"
// version = "0.1.0"
// edition = "2021"

// [dependencies]
// hyper-util = { version = "0.1.3", features = ["client-legacy"] }

fn main() {
    hyper_util::client::legacy::connect::Connected::new();
}

With RUSTFLAGS=-Zsanitizer=address, I run cargo +nightly build --target=x86_64-pc-windows-msvc

I expected to see this happen: build succeeds

Instead, this happened: Build fails:

note: libtokio-b91778b05568f23f.rlib(tokio-b91778b05568f23f.tokio.1a77ed8b4a2c54db-cgu.0.rcgu.o) : fatal error LNK1227: conflicting weak extern definition for '__odr_asan_gen___rust_panic_type_info'.  New default '.weak.__odr_asan_gen___rust_panic_type_info.default._ZN100_$LT$core..iter..adapters..take..Take$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$8try_fold17h072bc292ea794e70E' conflicts with old default '.weak.__odr_asan_gen___rust_panic_type_info.default._ZN102_$LT$core..iter..adapters..map..Map$LT$I$C$F$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h028b213dc72dac34E' in libtracing_core-a6cff17f7c0ffd01.rlib(tracing_core-a6cff17f7c0ffd01.tracing_core.3abebefd05f70947-cgu.0.rcgu.o)

Seems somwhat similar to https://github.com/rust-lang/rust/issues/85461, however setting -Ccodegen-units=1 does not workaround the issue.

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (ef8b9dcf2 2024-04-24)
binary: rustc
commit-hash: ef8b9dcf23700f2e2265317611460d3a65c19eff
commit-date: 2024-04-24
host: x86_64-pc-windows-msvc
release: 1.79.0-nightly
LLVM version: 18.1.4

MSVC version 14.39.33519

rcvalle commented 3 months ago

I couldn't reproduce it with the latest nightly build. Is this still an issue?

russelltg commented 3 months ago

Yeah, the reproducer I posted earlier seems to be fixed. However, the bug does still exist. New reproducer:

// Cargo.toml
// [package]
// name = "conflicting_weak_bug"
// version = "0.1.0"
// edition = "2021"

// [dependencies]
// tokio = { version = "1.39.2", features = ["rt-multi-thread"] }

fn main() {
    let _ = tokio::runtime::Builder::new_multi_thread()
        .build()
        .unwrap();
}

Tested with 1.82.0-nightly (64ebd39da 2024-08-03)+ MSVC 14.40.33807

This was actually my original reproducer, but I minimized it to hyper to have it be simpler.

samkearney commented 2 months ago

I am encountering the same issue in an app with a multi-threaded tokio runtime (although my version of the error message shows a symbol conflict between a different library and my main executable)