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

fix regression in panic_misaligned_pointer_dereference #1

Conversation

thomasdangl
Copy link
Owner

rust-lang#118362 introduced a regression that breaks pointer dereferencing in core.

use std::ptr;

pub fn main() {
    let a: *const u8 = ptr::null();
    dbg!(unsafe { *a });
}
[profile.dev]
panic = "abort"
[build]
target = "x86_64-pc-windows-msvc"

[unstable]
build-std = ["std", "panic_abort"]
build-std-features = ["panic_immediate_abort"]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"

Until 8de5bd0 this worked totally fine.
However, since the commit ended up in master, the linker is quite unhappy about the symbol:

  = note: rust-lld: error: undefined symbol: core::panicking::panic_misaligned_pointer_dereference::h89d210946737113d
          >>> referenced by C:\Users\User\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\windows\fs.rs:517
          >>>               libstd-93222e7335411a9e.rlib(std-93222e7335411a9e.std.f1f999d9f794207e-cgu.06.rcgu.o):(std::sys::windows::fs::File::readlink::ha67e29df7ba249d0)
          >>> referenced by C:\Users\User\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\windows\fs.rs:518
          >>>               libstd-93222e7335411a9e.rlib(std-93222e7335411a9e.std.f1f999d9f794207e-cgu.06.rcgu.o):(std::sys::windows::fs::File::readlink::ha67e29df7ba249d0)
          >>> referenced by C:\Users\User\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\windows\fs.rs:519
          >>>               libstd-93222e7335411a9e.rlib(std-93222e7335411a9e.std.f1f999d9f794207e-cgu.06.rcgu.o):(std::sys::windows::fs::File::readlink::ha67e29df7ba249d0)
          >>> referenced 33 more times

Is there a specific reason panic_misaligned_pointer_dereference is supposed to be inlined?
Otherwise I suggest we just avoid inlining it for panic_immediate_abort.

Perhaps this is also something to be added as an example for rust-lang#118393.

Best,
Thomas

@thomasdangl thomasdangl closed this Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant