generator-rs
generator-rs copied to clipboard
Bus error when running in debug mode with thread_rng() on Apple M1
When running the following program in debug mode, I get a bus error.
use generator::{Generator, Gn, done};
use rand::{thread_rng, Rng};
fn simple_generator<'a>() -> Generator<'a, (), i32>{
Gn::new_scoped(move |mut s| {
let v: i32 = thread_rng().gen();
s.yield_(v);
done!();
})
}
fn main() {
for v in simple_generator(){
println!("{}", v);
}
}
It runs fine in release mode, or when there is no thread_rng involved.
I'm on an M1 Mac, Ventura 13.0.1. Stable Rust (1.72.0).
I don't have a M1 Mac env now. It's likely the debug version stack alignment issue. E.g.
https://github.com/Xudong-Huang/generator-rs/blob/ea54d2f38bc1fbdbf6d9d45fee303f3185980e39/src/detail/asm/asm_x86_64_sysv_elf_gas.S#L14-L18
I don't have a M1 Mac env now. It's likely the debug version stack alignment issue. E.g.
https://github.com/Xudong-Huang/generator-rs/blob/ea54d2f38bc1fbdbf6d9d45fee303f3185980e39/src/detail/asm/asm_x86_64_sysv_elf_gas.S#L14-L18
it might be a stack overflow error
@Tassle could please test the master in your env again?
@Tassle could please test the master in your env again?
works fine on my Mac.
use generator::{Generator, Gn, done};
use rand::{thread_rng, Rng};
fn simple_generator<'a>() -> Generator<'a, (), i32>{
Gn::new_scoped(move |mut s| {
let v: i32 = thread_rng().gen();
s.yield_(v);
done!();
})
}
fn main() {
assert!(catch_unwind(|| {
for v in simple_generator(){
println!("{}", v);
}
}).is_err());
}
coroutine in thread 'main' has overflowed its stack
Process finished with exit code 0
sysctl -n machdep.cpu.brand_string
Apple M3 Pro