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

1.68.0 emits STATUS_ILLEGAL_INSTRUCTION on build #108978

Closed
rozensoftware opened this issue Mar 10, 2023 · 25 comments
Closed

1.68.0 emits STATUS_ILLEGAL_INSTRUCTION on build #108978

rozensoftware opened this issue Mar 10, 2023 · 25 comments
Labels
C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows

Comments

@rozensoftware
Copy link

Couldn't build with cargo build.
I tried this code:

fn main() {
    println!("Hello, world!");
}

I expected to see this happen:

the program should compile fine.

Instead, this happened:

error: could not compile nanny

Caused by:
process didn't exit successfully: rustc --crate-name nanny --edition=2021 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=203 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=5a2abc74c1c30893 --out-dir D:\Projects\nanny\target\debug\deps -C incremental=D:\Projekty\nanny\target\debug\incremental -L dependency=D:\Projects\nanny\target\debug\deps (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)

rustc --version --verbose:

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-pc-windows-msvc
release: 1.68.0
LLVM version: 15.0.6

Notes:

cargo check emits the same error.
cargo build --release works correctly.

Having Visual Studio 2022 v17.5.1 installed on my system.

@rozensoftware rozensoftware added the C-bug Category: This is a bug. label Mar 10, 2023
@workingjubilee
Copy link
Member

That's... weird.
What CPU/Windows OS are you running on?

@rozensoftware
Copy link
Author

CPU: AMD Phenom(tm) II X4 840 Processor 3.20 GHz
OS: Windows 10 Pro 64bit, 22H2

@workingjubilee
Copy link
Member

Huh.
Did a prior version of Rust work?

I do know the CPU you are using pushes the edges of Windows 10 support. I would have thought it was still "in the clear", but only barely. I'd ask you to attach a debugger to find where the illegal instruction is invoked but I am not really familiar with the Windows debugging tools.

@rozensoftware
Copy link
Author

Yes, previous version of Rust did work fine. I have dual booting computer with Linux also. 1.68 compiles correctly mentioned above code on Linux (and other projects also).
I am very sorry, but currently I do not have a ready environment to perform the above test.
I am aware that processor is old. But still, it's a mystery why this happened..

@workingjubilee workingjubilee added the O-windows-msvc Toolchain: MSVC, Operating system: Windows label Mar 10, 2023
@workingjubilee
Copy link
Member

So Windows fails, but Linux does not?
I don't know how to explain that...

@workingjubilee
Copy link
Member

Oh.This might be a consequence of a double-panic...

@rozensoftware
Copy link
Author

I'm glad you have found something. Yes, this fails only on Windows on my system configuration.

@GregGorin
Copy link

I have the same problem. CPU AMD Phenom II X6 1090T

@Kronprinz42
Copy link

I have the same problem. I used the standalone installer. Core 2 Duo E6320 processor. However, when using "cargo build --release" everything compiles successfully.

@BloodSharp
Copy link

BloodSharp commented Mar 14, 2023

Hello, I'm having the same issue with AMD Phenom II X4 945 CPU and Windows 11 Pro, building using "cargo build --release" seems to work.

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-pc-windows-msvc
release: 1.68.0
LLVM version: 15.0.6

PS: The stable-i686-pc-windows-msvc toolchain seems to work both on debug and release mode.

@lqd
Copy link
Member

lqd commented Mar 14, 2023

Could you try on nightly ? Especially the latest one, nightly-2023-03-14 for rustup, rustc 1.70.0-nightly (22f247c6f 2023-03-13) for rustc -vV.

I wonder if it's linked to the ThinLTO miscompilation #109067.

@ehuss
Copy link
Contributor

ehuss commented Mar 14, 2023

Also, if nightly doesn't help, can you try to use a debugger to see where it is faulting? You should be able to launch a debugger on rustc (the path can be shown via rustup which rustc), and copy the command-line arguments in. This can be done in Visual Studio if you have that installed.

@BloodSharp
Copy link

Could you try on nightly ? Especially the latest one, nightly-2023-03-14 for rustup, rustc 1.70.0-nightly (22f247c6f 2023-03-13) for rustc -vV.

I wonder if it's linked to the ThinLTO miscompilation #109067.

Alright, I installed nightly, by typing:

$ rustup install nightly
info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
info: latest update on 2023-03-16, rust version 1.70.0-nightly (ab654863c 2023-03-15)
(...)
$ rustup toolchain list
stable-i686-pc-windows-msvc (default)
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc
$ rustup default nightly-x86_64-pc-windows-msvc
info: using existing install for 'nightly-x86_64-pc-windows-msvc'
info: default toolchain set to 'nightly-x86_64-pc-windows-msvc'

Then finally both debug and release mode works: 👍

$ cargo build
$ cargo build --release

I hope this help the people which having the same issue...

@Noratrieb
Copy link
Member

Thanks! Could you try bisecting the fix using cargo-bisect-rustc?
After installing it, try cargo-bisect-rustc --start 2023-03-01 --end 2023-03-16 --regress success (I think that's the right command)

@lqd
Copy link
Member

lqd commented Mar 16, 2023

If bisecting is not possible/easy, checking with another nightly where we know the miscompilation is still present would otherwise be helpful: rustup install nightly-2023-03-13 and run your builds like so: cargo +nightly-2023-03-13 build.

If we're correct, this should fail with the previous STATUS_ILLEGAL_INSTRUCTION error.

Thanks in advance.

@BloodSharp
Copy link

Hello, I installed caro-bisect-rustc using nightly x64 msvc and it found a regression...

Regression in nightly-2023-03-14

The current status is cloning the rust repository, I'll let you know once it finish.

@lqd
Copy link
Member

lqd commented Mar 16, 2023

--access github should avoid cloning the repo, but nightly-2023-03-14 is indeed the one where the change should have happened. Thanks!

@BloodSharp
Copy link

cargo-bisect-rustc has finished! It's safe to remove all the targets and rust.git from my repository folder now?

Regression in 22f247c

searched nightlies: from nightly-2023-03-01 to nightly-2023-03-16
regressed nightly: nightly-2023-03-14
searched commit range: 7b4f489...22f247c
regressed commit: 22f247c

bisected with cargo-bisect-rustc v0.6.5

Host triple: x86_64-pc-windows-msvc
Reproduce with:

cargo bisect-rustc 2023-03-01 --end 2023-03-16 --regress success

@lqd
Copy link
Member

lqd commented Mar 16, 2023

Thanks a bunch! It is indeed safe to remove all these.

@mac198442
Copy link

mac198442 commented Mar 22, 2023

Not sure if this helps but issue does not exist with rustc 1.67.1 or 1.70.0-nighlty Only an issue with 1.68.0 and 1.69.0-beta.1

also I have access to 4 AMD systems and results are:

FAILS AMD Phenom(tm) II X3 710 Processor 2.60 GHz
FAILS AMD A6-3420M with Radeon(tm) HD Grpahics 1,50 GHz
WORKS AMD A6-4400M APU with Radeon(tm) HD Graphics 2.70 GHz
WORKS AMD Ryzen 7 3700U with Radeon Vega Mobile Gfx 2.30 GHz

@mac198442
Copy link

but I will also repeat here that although it seems this is fixed in 1.70.0 the fix needs to backported to the beta and stable because it is not good for rust to have the latest version of Firefox not being able to be built with a lot of AMD processors using the latest stable version of rust.

@ehuss
Copy link
Contributor

ehuss commented Mar 22, 2023

@mac198442 Sorry for the miscommunication. This was mentioned on #109067 but not here. A patch release should come out tomorrow. See https://blog.rust-lang.org/inside-rust/2023/03/20/1.68.1-prerelease.html and https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1681-2023-03-23.

@mac198442
Copy link

OK just thought my experience was fails on 50% of AMD CPUs I had to test seemed widespread enough to need a backport.

@mac198442
Copy link

mac198442 commented Mar 23, 2023

I can verify that my issue is resolved after updating to 1.68.1.

Thanks for the good work.

@Noratrieb
Copy link
Member

I will close the issue as it's fixed now. We can't really add a test for it right now. I will open a separate issue about running tests for dist builds, which should prevent this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows
Projects
None yet
Development

No branches or pull requests

9 participants