Skip to content
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

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

Closed
russelltg opened this issue Apr 26, 2024 · 3 comments · Fixed by #132773
Closed

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

russelltg opened this issue Apr 26, 2024 · 3 comments · Fixed by #132773
Labels
A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows

Comments

@russelltg
Copy link

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 #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

@russelltg russelltg added the C-bug Category: This is a bug. label Apr 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 26, 2024
@saethlin saethlin added A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality O-windows-msvc Toolchain: MSVC, Operating system: Windows labels May 9, 2024
@saethlin saethlin changed the title Unable to link use of hypr_util with -Zsanitizer=address on msvc Unable to link use of hyper_util with -Zsanitizer=address on msvc May 24, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 24, 2024
@rcvalle
Copy link
Member

rcvalle commented Aug 3, 2024

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

@russelltg
Copy link
Author

russelltg commented Aug 4, 2024

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
Copy link

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)

bors added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2024
PassWrapper: disable UseOdrIndicator for Asan Win32

As described in https://reviews.llvm.org/D137227 UseOdrIndicator should be disabled on Windows since link.exe does not support duplicate weak definitions.

Fixes rust-lang#124390.

Credits also belong to `@1c3t3a`  who worked with me on this.
We are currently testing this on a Windows machine.
@bors bors closed this as completed in e3c76c5 Nov 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 14, 2024
Rollup merge of rust-lang#132773 - jakos-sec:fix-asan-win32, r=jieyouxu

PassWrapper: disable UseOdrIndicator for Asan Win32

As described in https://reviews.llvm.org/D137227 UseOdrIndicator should be disabled on Windows since link.exe does not support duplicate weak definitions.

Fixes rust-lang#124390.

Credits also belong to `@1c3t3a`  who worked with me on this.
We are currently testing this on a Windows machine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants