oyashio
oyashio copied to clipboard
thread '<unnamed>' panicked at 'assertion failed: `(left == right)` (left: `2`, right: `0`)', src/libstd/sync/mpsc/shared.rs:504
I am trying to use this library for single producer/multi-consumer scenario. Code is
fn main() {
let (mut st, mut sr) = Stream::default();
let mut children = vec![];
// let mut sr2 = sr.clone();
for n in (1..10) { st.send(n) }
for i in 0..3 {
let mut s = sr.clone();
children.push(thread::spawn(move || {
let mut counter = 0;
for entry in s.poll() {
println!("Thread: {:?} counter:{:?} {:?}", i, counter, entry);
counter = counter + 1;
}
}));
}
for child in children {
// Wait for the thread to finish. Returns a result.
let _ = child.join();
}
return;
I get following error:
Thread: 2 counter:0 1
Thread: 2 counter:1 2
Thread: 2 counter:2 3
Thread: 2 counter:3 4
thread 'Thread: 2 counter:4 5
<unnamed>Thread: 2 counter:5 6
' panicked at 'assertion failed: `(left == right)` (left: `4334870528`, right: `0`)Thread: 2 counter:6 7
', src/libstd/sync/mpsc/shared.rsThread: 2 counter:7 8
:503Thread: 2 counter:8 9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread '<unnamed>' panicked at 'upgrading again', src/libstd/sync/mpsc/oneshot.rs:225
thread '<unnamed>' panicked at 'assertion failed: `(left == right)` (left: `2`, right: `0`)', src/libstd/sync/mpsc/shared.rs:504
stack backtrace:
0: 0x101a48ea3 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::hbdeac7eba2f064c6
1: 0x101a4a7fd - std::panicking::default_hook::{{closure}}::h9e0a6ca9bb64b479
2: 0x101a4a3c4 - std::panicking::default_hook::h9043ae80af471c9f
3: 0x101a4cf67 - std::panicking::rust_panic_with_hook::h05996066754c6be9
4: 0x101a4ce54 - std::panicking::begin_panic::h9fecf34da42eb910
5: 0x101a4cd72 - std::panicking::begin_panic_fmt::he5aad713258a67c3
6: 0x101a403ac - core::ptr::drop_in_place::h6d54e2655a3206ca
7: 0x101a3cd65 - <alloc::arc::Arc<T>>::drop_slow::h79abeb192a5a3c58
8: 0x101a41f7a - <std::sync::mpsc::Sender<T> as core::clone::Clone>::clone::h42047a5f4d0c4089
9: 0x101a3d32f - <oyashio::StreamR<T>>::get_try::hd29c3a6e5989cfa6
10: 0x101a3db8d - std::panicking::try::do_call::hb5e39cb158b9b4ff
11: 0x101a4dc4a - __rust_maybe_catch_panic
12: 0x101a41133 - <F as alloc::boxed::FnBox<A>>::call_box::hb6f5595ad15b413d
13: 0x101a49e64 - std::sys::imp::thread::Thread::new::thread_start::h4008e1859fbd98b8
14: 0x7fff90ee899c - _pthread_body
15: 0x7fff90ee8919 - _pthread_start
thread panicked while panicking. aborting.
Illegal instruction: 4
cargo version
cargo 0.19.0-nightly (4e95c6b41 2017-03-23)
rustc --version
rustc 1.18.0-nightly (5309a3e31 2017-04-03)
Interesting! This library has not seen an update since the initial rust stable, and it looks like from the first assertion that the pointer is invalid. I imagine the threading backend has changed some how.
Are you on a Linux distro? Have you tried this on stable yet?
Soon as I get a chance I'm going to dig deeper! If you have a chance clone the repo and run the tests :)
I am using Mac. I will try to run tests when i get time.
I ran the test cases. All of them are passing.
cargo test
running 7 tests
test tests::bench_stream ... ok
test tests::test_stream ... ok
test tests::test_stream_close ... ok
test tests::test_stream_dupe ... ok
test tests::test_stream_drop ... ok
test tests::test_stream_dupe_broadcast ... ok
test tests::test_stream_merge ... ok
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured
Doc-tests oyashio
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
Ok hmm, is that the exact code? Looks like a closing bracket might be misplaced. This at be a bug due to the main program not outliving the threads, odd enough. Paste the exact failing code if you can. Or was that all of it?
Thread: 1 counter:0 1 Thread: 1 counter:1 2 Thread: 1 counter:2 3 Thread: 1 counter:3 4 Thread: 1 counter:4 5 Thread: 0 counter:0 1 Thread: 1 counter:5 6 Thread: 0 counter:1 2 Thread: 1 counter:6 7 Thread: 0 counter:2 3 Thread: 1 counter:7 8 Thread: 2 counter:0 1 Thread: 0 counter:3 4 Thread: 1 counter:8 9 Thread: 0 counter:4 5 Thread: 2 counter:1 2 Thread: 0 counter:5 6 Thread: 2 counter:2 3 Thread: 0 counter:6 7 Thread: 2 counter:3 4 Thread: 0 counter:7 8 Thread: 2 counter:4 5 Thread: 0 counter:8 9 Thread: 2 counter:5 6 Thread: 2 counter:6 7 Thread: 2 counter:7 8 Thread: 2 counter:8 9 test tests::test_issue_3 ... ok
I ran this code and it completed fine. I updated this to the latest stable and pushed a new version to crates, when you have a chance try again! Also, are you running that assertion somewhere?
' panicked at 'assertion failed: `(left == right)` (left: `4334870528`, right: `0`)Thread: 2 counter:6 7
', src/libstd/sync/mpsc/shared.rs
Here is a code which I am able to reproduce consistently.
https://github.com/rohitjoshi/oyashio_test/
No, this assertion seem to be part of mpsc channel used in oyashio library
I switch to crossbeam deque to replace this library and seem to be working fine.
"No, this assertion seem to be part of mpsc channel used in oyashio library"
This library makes no runtimes assertions, that assertion is apart of the standard lib in nightly. I'll look in to it more closely this week, looks to be a rust bug at this point :-/ Thanks