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

STATUS_STACK_BUFFER_OVERRUN / nondeterministic execution in loom test #38

Open
simonwuelker opened this issue May 8, 2024 · 2 comments

Comments

@simonwuelker
Copy link
Contributor

simonwuelker commented May 8, 2024

The send_recv_different_threads test (tests/loom.rs) occasionally fails with STATUS_STACK_BUFFER_OVERRUN on x86_64-pc-windows-msvc. Only default features, rustc 1.79.0-nightly (3a36386dc 2024-04-25).

Curiously, sometimes loom panics before this happens:

---- send_recv_different_threads stdout ----
thread 'send_recv_different_threads' panicked at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\path.rs:171:14:
Reached unexpected exploration state. Is the model fully deterministic?
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe/library\std\src\panicking.rs:652
   1: core::panicking::panic_fmt
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe/library\core\src\panicking.rs:72
   2: core::panicking::panic_display<ref$<str$> >
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe/library\core\src\panicking.rs:263
   3: core::option::expect_failed
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe/library\core\src\option.rs:1994
   4: enum2$<core::option::Option<loom::rt::object::Ref<loom::rt::path::Load> > >::expect<loom::rt::object::Ref<loom::rt::path::Load> >
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe\library\core\src\option.rs:895
   5: loom::rt::path::Path::branch_load
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\path.rs:169
   6: loom::rt::atomic::impl$0::rmw::closure$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >,tuple$<> >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\atomic.rs:321
   7: loom::rt::synchronize::closure$0<loom::rt::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >,tuple$<> >,enum2$<core::result::Result<u8,tuple$<> > >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\mod.rs:141
   8: loom::rt::scheduler::impl$0::with_execution::closure$0<loom::rt::synchronize::closure_env$0<loom::rt::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\scheduler.rs:48
   9: loom::rt::scheduler::impl$0::with_state::closure$0<loom::rt::scheduler::impl$0::with_execution::closure_env$0<loom::rt::synchronize::closure_env$0<loom::rt::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,lo
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\scheduler.rs:130
  10: scoped_tls::ScopedKey<core::cell::RefCell<loom::rt::scheduler::State> >::with<core::cell::RefCell<loom::rt::scheduler::State>,loom::rt::scheduler::impl$0::with_state::closure_env$0<loom::rt::scheduler::impl$0::with_execution::closure_env$0<loom::rt::synch
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scoped-tls-1.0.1\src\lib.rs:171
  11: loom::rt::scheduler::Scheduler::with_state<loom::rt::scheduler::impl$0::with_execution::closure_env$0<loom::rt::synchronize::closure_env$0<loom::rt::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\scheduler.rs:130
  12: loom::rt::scheduler::Scheduler::with_execution<loom::rt::synchronize::closure_env$0<loom::rt::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >,tup
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\scheduler.rs:48
  13: loom::rt::execution<loom::rt::synchronize::closure_env$0<loom::rt::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >,tuple$<> >,enum2$<core::result
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\mod.rs:171
  14: loom::rt::synchronize<loom::rt::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >,tuple$<> >,enum2$<core::result::Result<u8,tuple$<> > > >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\mod.rs:138
  15: loom::rt::atomic::Atomic<u8>::rmw<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >,tuple$<> >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\atomic.rs:309
  16: loom::sync::atomic::atomic::Atomic<u8>::try_rmw<u8,loom::sync::atomic::atomic::impl$0::rmw::closure_env$0<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >,tuple$<> >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\sync\atomic\atomic.rs:57
  17: loom::sync::atomic::atomic::Atomic<u8>::rmw<u8,loom::sync::atomic::atomic::impl$0::swap::closure_env$0<u8> >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\sync\atomic\atomic.rs:49
  18: loom::sync::atomic::atomic::Atomic<u8>::swap<u8>
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\sync\atomic\atomic.rs:62
  19: loom::sync::atomic::int::AtomicU8::swap
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\sync\atomic\int.rs:70
  20: oneshot::impl$5::recv_deadline::closure$0<u128>
             at .\src\lib.rs:711
  21: oneshot::Receiver<u128>::start_recv_ref<u128,oneshot::errors::RecvTimeoutError,oneshot::impl$5::recv_deadline::closure_env$0<u128> >
             at .\src\lib.rs:798
  22: oneshot::Receiver<u128>::recv_deadline<u128>
             at .\src\lib.rs:684
  23: oneshot::Receiver<u128>::recv_timeout<u128>
             at .\src\lib.rs:639
  24: loom::send_recv_different_threads::closure$0::closure$0
             at .\tests\loom.rs:44
  25: loom::thread::spawn_internal::closure$0<loom::send_recv_different_threads::closure$0::closure_env$0,tuple$<> >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\thread.rs:161
  26: loom::rt::spawn::closure$1<loom::thread::spawn_internal::closure_env$0<loom::send_recv_different_threads::closure$0::closure_env$0,tuple$<> > >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\mod.rs:76
  27: core::ops::function::FnOnce::call_once<loom::rt::spawn::closure_env$1<loom::thread::spawn_internal::closure_env$0<loom::send_recv_different_threads::closure$0::closure_env$0,tuple$<> > >,tuple$<> >
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe\library\core\src\ops\function.rs:250
  28: alloc::boxed::impl$48::call_once<tuple$<>,dyn$<core::ops::function::FnOnce<tuple$<>,assoc$<Output,tuple$<> > > >,alloc::alloc::Global>
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe\library\alloc\src\boxed.rs:2022
  29: loom::rt::scheduler::spawn_threads::closure$0::closure$0
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\loom-0.5.6\src\rt\scheduler.rs:149
  30: generator::gen_impl::impl$9::init_code::closure$0<enum2$<core::option::Option<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<>,assoc$<Output,tuple$<> > > >,alloc::alloc::Global> > >,tuple$<>,loom::rt::scheduler::spawn_threads::closure$0::closur
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\generator-0.7.5\src\gen_impl.rs:336
  31: generator::stack::StackBox<generator::gen_impl::impl$9::init_code::closure_env$0<enum2$<core::option::Option<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<>,assoc$<Output,tuple$<> > > >,alloc::alloc::Global> > >,tuple$<>,loom::rt::scheduler::s
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\generator-0.7.5\src\stack\mod.rs:139
  32: generator::stack::Func::call_once
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\generator-0.7.5\src\stack\mod.rs:121
  33: generator::gen_impl::gen_init::closure$0
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\generator-0.7.5\src\gen_impl.rs:552
  34: core::ops::function::FnOnce::call_once<generator::gen_impl::gen_init::closure_env$0,tuple$<> >
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe\library\core\src\ops\function.rs:250
  35: std::panicking::try::do_call<generator::gen_impl::gen_init::closure_env$0,tuple$<> >
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe\library\std\src\panicking.rs:559
  36: generator::stack::impl$13::fmt
  37: std::panicking::try<tuple$<>,generator::gen_impl::gen_init::closure_env$0>
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe\library\std\src\panicking.rs:523
  38: std::panic::catch_unwind<generator::gen_impl::gen_init::closure_env$0,tuple$<> >
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe\library\std\src\panic.rs:149
  39: generator::gen_impl::catch_unwind_filter<generator::gen_impl::gen_init::closure_env$0,tuple$<> >
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\generator-0.7.5\src\gen_impl.rs:543
  40: generator::gen_impl::gen_init
             at C:\Users\Lenovo\.cargo\registry\src\index.crates.io-6f17d22bba15001f\generator-0.7.5\src\gen_impl.rs:570
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

It appears that the callback from recv_deadline is doing something nasty when reaching the end of the timeout...

I'm seeing four different results for this test in total:

  • Test passes
  • Test fails
  • Test crashes
  • Loom panics
@simonwuelker
Copy link
Contributor Author

@faern
Copy link
Owner

faern commented May 23, 2024

I just upgraded loom by quite a few versions. Can you still reproduce the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants