You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running this code with cargo run --release, it prints Illegal instruction and immedialy exits with error code 132. This only happens when running the release build, the debug build created by cargo build just runs endlessly as expected.
use std::thread;fnmain(){let thread = thread::spawn(move || {let x = 0isize;loop{
x % 1;}});
thread.join().unwrap();}
This happens when x is of any signed integer type. When I replace the content of the loop with 0isize % 1;, the error does not occur. Using something like while true instead of loop leads to the same error.
I did not modify the Cargo.toml generated by cargo new:
[package]
name = "bug"
version = "0.1.0"
authors = ["felix <felix.a.lehner@googlemail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Meta
I have tested this problem on two Linux machines (uname -a): Linux wheatly 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
and Linux raspberrypi 5.4.79-v7l+ #1373 SMP Mon Nov 23 13:27:40 GMT 2020 armv7l GNU/Linux
both running the same rust version: rustc --version --verbose:
Thanks for the report! Infinite loops are undefined behavior in LLVM, which can result in anything happening. This is a known issue, closing as a duplicate of #28728.
When running this code with
cargo run --release
, it printsIllegal instruction
and immedialy exits with error code 132. This only happens when running the release build, the debug build created bycargo build
just runs endlessly as expected.This happens when x is of any signed integer type. When I replace the content of the loop with
0isize % 1;
, the error does not occur. Using something likewhile true
instead ofloop
leads to the same error.I did not modify the
Cargo.toml
generated bycargo new
:Meta
I have tested this problem on two Linux machines (
uname -a
):Linux wheatly 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
and
Linux raspberrypi 5.4.79-v7l+ #1373 SMP Mon Nov 23 13:27:40 GMT 2020 armv7l GNU/Linux
both running the same rust version:
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: