-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
need test of external linkage symbol collision #61232
Comments
Ah I think I just found a way to cause that code to fire. |
For the record, here is how I did it (play): #![feature(linkage)]
mod dep {
extern {
#[linkage="external"]
pub static collision: *const i32;
}
}
#[no_mangle]
pub static _rust_extern_with_linkage_collision: i32 = 0;
fn main() {
unsafe {
println!("{:p}", &dep::collision);
}
} |
Another quick note: this variant test case ("weird.rs") is causing non-deterministic memory corruption within my local build of (but I have not yet observed such memory corruption on the playpen itself.) // This strange test is (sometimes?) causing memory corruption within
// the compiler itself.
#![feature(linkage)]
mod dep1 {
extern {
#[linkage="external"]
pub static collision: *const i32;
}
}
#[no_mangle]
pub static collision: usize = 0;
fn main() {
unsafe {
println!("{:p}", &dep1::collision);
}
} Click for gdb run of rustc with backtrace
(I'm not adding it as a test case since we don't currently have a policy of adding tests that are known to fail, especially not in this manner. But it might be good to get to the bottom of this.) Update: The failure noted here may be an instance of long-standing (but improperly tracked) bugs with our implementation of |
…stic, r=petrochenkov Fix linkage diagnostic so it doesn't ICE for external crates Fix linkage diagnostic so it doesn't ICE for external crates (As a drive-by improvement, improved the diagnostic to indicate *why* `*const T` or `*mut T` is required.) Fix rust-lang#59548 Fix rust-lang#61232
…stic, r=petrochenkov Fix linkage diagnostic so it doesn't ICE for external crates Fix linkage diagnostic so it doesn't ICE for external crates (As a drive-by improvement, improved the diagnostic to indicate *why* `*const T` or `*mut T` is required.) Fix rust-lang#59548 Fix rust-lang#61232
The
#[linkage]
feature has some code that generates a symbol, e.g. forfoo
it generatesextern_with_linkage_foo
.We have some code that causes the compilation to fail if it can detect that the generated symbol is the source of a collision.
rust/src/librustc_codegen_llvm/consts.rs
Lines 130 to 147 in 4680580
But as far as I can tell, we have no tests of this feature.
While I was working on PR #61231, I tried to manufacture such a test, but it was not obvious to me how to actually set things up to make the scenario happen. I don't want to forget about the need for this test after I put that task aside, so I'm filing this issue.
The text was updated successfully, but these errors were encountered: