-
Notifications
You must be signed in to change notification settings - Fork 13.3k
STATUS_ACCESS_VIOLATION happens frequently with rust 1.83 under windows x64 environment #134119
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
Comments
Given that the code is trivial I think that is unlikely. We test in CI and 1.83 was released on 28 November, yet this is the first report. I guess it is possible this is a result of an incremental bug, in which case |
I can't repro this locally on native |
@maple19out if you go back to 1.81.0, and do a compile binary -> run binary multiple times -> remove output artifacts (e.g. in a loop), does it also segfault? Does it also segfault consistently like this in a loop with 1.83.0? How about nightly, or beta? |
could you run memtest86? might be a hardware issue |
well I'm not sure whether it matters, i'll provide detailed context for the error.
code// src/smart_pointer_application/main.rs
use std::io::{stdin, stdout, Write};
fn get_user_input() -> String {
let mut s = String::new();
let _ = stdout().flush();
stdin()
.read_line(&mut s)
.expect("Did not enter a correct string");
if let Some('\n') = s.chars().next_back() {
s.pop();
}
if let Some('\r') = s.chars().next_back() {
s.pop();
}
s
}
trait GenSerialData {
fn get_input(&mut self);
fn generate(&self) -> Option<&str>;
}
struct UserID {
digit: u32,
id: Option<String>,
}
impl GenSerialData for UserID {
fn get_input(&mut self) {
println!("Please input {}-digits User ID: ", self.digit);
self.id = Some(get_user_input());
}
fn generate(&self) -> Option<&str> {
self.id.as_ref().map(|x| x.as_str())
}
}
struct ProductID {
digit: u32,
id: Option<String>,
}
impl GenSerialData for ProductID {
fn get_input(&mut self) {
println!("Please input {}-digits Product ID: ", self.digit);
self.id = Some(get_user_input());
}
fn generate(&self) -> Option<&str> {
self.id.as_ref().map(|x| x.as_str())
}
}
//fn collect_data(items: &mut Vec<Box<dyn GenSerialData>>) { // If you want to use Vec<Box<dyn GenSerialData>> in main function
fn collect_data(items: &mut [Box<dyn GenSerialData>]) {
for item in items.iter_mut() {
item.get_input();
}
}
// &[&dyn GenSerialData] is wrong!
//fn generate_serial(items: &Vec<Box<dyn GenSerialData>>) -> String { // If you want to use Vec<Box<dyn GenSerialData>> in main function
fn generate_serial(items: &[Box<dyn GenSerialData>]) -> String {
let mut data = String::new();
for item in items.iter() {
data.push_str(item.generate().unwrap());
}
data
}
fn main() {
println!("hello");
let userid = UserID { digit: 4, id: None };
let productid = ProductID { digit: 8, id: None };
// Vec<&dyn GenSerialData> is wrong!
//let mut items: Vec<Box<dyn GenSerialData>> = vec![Box::new(userid), Box::new(productid)];
let mut items = [Box::new(userid), Box::new(productid)];
collect_data(&mut items);
let serial = generate_serial(&items);
println!("Serial generated: {}", serial);
} and I got compile error below, compile error log
let mut items = [Box::new(userid), Box::new(productid)]; // automatic, but wrong inference so I changed the order of elements of items array as below let mut items = [Box::new(productid), Box::new(userid)]; and I started to get STATUS_ACCESS_VIOLATION... @ChrisDenton I tried cargo clean & cargo build, power off & on my computer, making a new crate with cargo new, but still randomly having the same problem, but I also couldn't reproduce it on another windows machine. May be the error is dependent to my computer. @jieyouxu I tested various rust versions and results are
@Noratrieb I couldn't run memtest86 right now, but I don't expect hardware flaw on the machine... I'll try out later Thanks for the comments. I'm quite suspicious with my pc environment right now... |
@maple19out You may wish to review other issues we've root-caused to defective hardware. In particular, it is useful to keep in mind a CPU that performs acceptably at other applications may fail when executing a stress-test that pushes the hardware to its limits. The Rust compiler is exactly such a stress test, and the performance characteristics of the compiler change between versions in ways that can serve as an inflection point. |
I tried this code:
I expected to see this happen:
Just a normal "hihi" string printed out on my console
Instead, this happened: explanation
Meta
rustc --version --verbose
:Backtrace
Hi, I used rust 1.81 before and upgraded to 1.83 today. When I write any codes and execute through 'cargo run' command, error happens frequently and randomly. I tried this on wsl, but it was fine.
I guess there might be some bug with recently rust compiler (version 1.83) under windows / x86_64 environment
The text was updated successfully, but these errors were encountered: