Closed steveklabnik closed 10 years ago
From what I'm seeing here(debugger wise) the problem looks to stem from the call to channel.try_recv
in the have_dinner
function.
Inside try_recv
we enter the loop, make it through the first unsafe match and then the problem appears to occur in the Oneshot
branch when we try to match again.
Can you describe the system that you're running on as well as the cargo/rustc versions you're using? I've been unable to reproduce the segfault on the most recent nightly on both linux and osx.
Oh sorry, I'm running Windows here. Latest installer version.
C:\Windows\System32>rustc --version
rustc 0.12.0-pre-nightly (d7cfc34a2 2014-08-02 00:31:03 +0000)
After restarting into Xubuntu and updating I recompiled there and got a segfault. I get rust from the hansjorg/rust PPA.
magisun@magimobile-ubuntu:~$ rustc --version
rustc 0.12.0-pre
I'm running off of a Toshiba Satellite L875D-S7210 with an AMD A6-4400M APU. Windows is 64bit and Xubuntu is 32bit.
Ah, found it.
Nominating and cc @pcwalton, this seems bad and related to the recent removal of for-loop desugaring.
Assigning P-backcompat-lang, 1.0 milestone.
Simpler reproduction (it's not related to fixed sized arrays, updating title):
fn main() {
let x = Some(box 1i);
for &a in x.iter() {
}
}
If you want to see a segfault you have to do something in the loop and iterate twice:
fn main() {
let x = [box 1i, box 2i];
for &a in x.iter() {
println!("{}", a);
}
for &a in x.iter() {
println!("{}", a);
}
}
This prints 1 and 2, then stalls a bit, then segfaults.
Updated description
for
loops allow moving out of fixed size arrays. This code compiles and should not compile.Original description
segfault with channels
I don't know how to make this test case smaller, but...
https://github.com/steveklabnik/dining_philosophers/commit/52ca03637a750f603f70c1d3b17d4326a2ae5eaa
This commit introduces a segfault.
Seems bad.