-
Notifications
You must be signed in to change notification settings - Fork 13k
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
tracing-core tests fail on nightly with codegen-units=1 opt-level>0, probably due to LLVM 17 #114699
Comments
Bisecting locally, I think the cause is llvm/llvm-project@336d728 |
Confirmed that at llvm/llvm-project@487ab39 with llvm/llvm-project@336d728 backed out everything works, that 336d728 change is definitely what triggered this. |
thanks for bisecting this @durin42! Stacktrace of the failing test
WG-prioritization assigning priority (Zulip discussion). Ideally we'd like a small reproducible @rustbot label -I-prioritize +P-critical +T-compiler +E-needs-mcve cc: @nikic |
On LLVM 17 this compiles down to an address comparison between TEST_CALLSITE_1 and TEST_CALLSITE_2, which get allocated at the same address. Are ZST statics supposed to have distinct addresses? |
Okay, pretty sure the answer to that is "no". As such, I think this test was just passing by luck previously. The test passes for me if I modify it like this to give the callsites distinct addresses: diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs
index 80ca065b..3dc40738 100644
--- a/tracing-core/src/field.rs
+++ b/tracing-core/src/field.rs
@@ -978,8 +978,8 @@ mod test {
use super::*;
use crate::metadata::{Kind, Level, Metadata};
- struct TestCallsite1;
- static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1;
+ struct TestCallsite1(u8);
+ static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1(0);
static TEST_META_1: Metadata<'static> = metadata! {
name: "field_test1",
target: module_path!(),
@@ -999,8 +999,8 @@ mod test {
}
}
- struct TestCallsite2;
- static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2;
+ struct TestCallsite2(u8);
+ static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2(0);
static TEST_META_2: Metadata<'static> = metadata! {
name: "field_test2",
target: module_path!(), |
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have different addresses. However, as they are zero-sized types, this is not guaranteed. This fixes the test failure with LLVM 17 and certain optimization options reported at rust-lang/rust#114699.
I submitted tokio-rs/tracing#2681 to fix the test, assuming my analysis here is correct. |
I wasn't sure initially, but looking at it the PartialEq impl for Identifier is relying on core::ptr::eq and so I agree that the code was working merely by good fortune. I wonder if we should strengthen the warning in the docs for core::ptr::eq to make it clear that ZSTs can behave in unexpected ways. |
I'm not sure if this comment should go in |
Going to close this issue, as the problem is not on the rustc/LLVM side. |
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have different addresses. However, as they are zero-sized types, this is not guaranteed. This fixes the test failure with LLVM 17 and certain optimization options reported at rust-lang/rust#114699.
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have different addresses. However, as they are zero-sized types, this is not guaranteed. This fixes the test failure with LLVM 17 and certain optimization options reported at rust-lang/rust#114699.
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have different addresses. However, as they are zero-sized types, this is not guaranteed. This fixes the test failure with LLVM 17 and certain optimization options reported at rust-lang/rust#114699.
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have different addresses. However, as they are zero-sized types, this is not guaranteed. This fixes the test failure with LLVM 17 and certain optimization options reported at rust-lang/rust#114699.
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have different addresses. However, as they are zero-sized types, this is not guaranteed. This fixes the test failure with LLVM 17 and certain optimization options reported at rust-lang/rust#114699.
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have different addresses. However, as they are zero-sized types, this is not guaranteed. This fixes the test failure with LLVM 17 and certain optimization options reported at rust-lang/rust#114699.
Code
The tracing-core crate, versions 0.1.30 and 0.1.31 (as well as git 941b1591) fails tests:
RUSTFLAGS='-Ccodegen-units=1 -Copt-level=1' cargo +nightly test
givestest field::test::value_sets_with_fields_from_other_callsites_are_empty ... FAILED
Version it worked on
Works in beta, and worked in nightly as of ~a week ago. I think the difference is the LLVM 17 upgrade. We've been chasing this defect for a couple weeks inside Google, where we run Rust and LLVM HEAD, and it showed up for us when we started doing more in
opt-level=1
.Version with regression
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged +A-LLVM
The text was updated successfully, but these errors were encountered: