Skip to content

16k-aligned statics crash rustc on Windows #135752

Open
@purplesyringa

Description

@purplesyringa
Contributor
#[repr(align(16384))]
struct HighAlignment;

static EXAMPLE: HighAlignment = const { HighAlignment };

fn main() {}
$ cargo build --target x86_64-pc-windows-gnu
...
error: could not compile `cringe` (bin "cringe"); 2 warnings emitted

Caused by:
  process didn't exit successfully: `/home/purplesyringa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name cringe --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=211 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=2b980327f571f145 -C extra-filename=-97496ab9b6118996 --out-dir /home/purplesyringa/cringe/target/x86_64-pc-windows-gnu/debug/deps --target x86_64-pc-windows-gnu -C incremental=/home/purplesyringa/cringe/target/x86_64-pc-windows-gnu/debug/incremental -L dependency=/home/purplesyringa/cringe/target/x86_64-pc-windows-gnu/debug/deps -L dependency=/home/purplesyringa/cringe/target/debug/deps` (signal: 4, SIGILL: illegal instruction)

Also reproduces on other ABIs, also gives STATUS_ILLEGAL_INSTRUCTION when building on Windows. Also applies to thread locals. Something something IMAGE_SCN_ALIGN_ stops at 8k and LLVM fails an assertion?

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (419b3e2d3 2025-01-15)
binary: rustc
commit-hash: 419b3e2d3e350822550eee0e82eeded4d324d584
commit-date: 2025-01-15
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.6

@rustbot label +I-crash +T-compiler +A-LLVM +E-needs-investigation +O-windows

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
E-needs-investigationCall for partcipation: This issues needs some investigation to determine current status
I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
O-windowsOperating system: Windows
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jan 20, 2025
changed the title [-]16k-aligned statics crash rustc[/-] [+]16k-aligned statics crash rustc on Windows[/+] on Jan 20, 2025
theemathas

theemathas commented on Jan 20, 2025

@theemathas
Contributor

Duplicate of #70144?

added
O-windows-gnuToolchain: GNU, Operating system: Windows
and removed
O-windowsOperating system: Windows
on Jan 20, 2025
purplesyringa

purplesyringa commented on Jan 20, 2025

@purplesyringa
ContributorAuthor

Indeed seems so, though this bug report applies to non-MSVC linkers too. @jieyouxu I'd like to merge this bug into that one, thoughts?

added
O-windowsOperating system: Windows
and removed
O-windows-gnuToolchain: GNU, Operating system: Windows
on Jan 20, 2025
jieyouxu

jieyouxu commented on Jan 20, 2025

@jieyouxu
removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
E-needs-investigationCall for partcipation: This issues needs some investigation to determine current status
on Jan 20, 2025
jieyouxu

jieyouxu commented on Jan 21, 2025

@jieyouxu
Member

Reopening because the other issue is not quite the same.

added
A-reprArea: the `#[repr(stuff)]` attribute
A-alignArea: alignment control (`repr(align(N))` and so on)
E-needs-investigationCall for partcipation: This issues needs some investigation to determine current status
on Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-alignArea: alignment control (`repr(align(N))` and so on)A-reprArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.E-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-windowsOperating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @theemathas@purplesyringa@jieyouxu@rustbot

        Issue actions

          16k-aligned statics crash rustc on Windows · Issue #135752 · rust-lang/rust