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

wrapping_rem called with a value of zero #156

Open
michael-temp opened this issue Sep 15, 2023 · 4 comments
Open

wrapping_rem called with a value of zero #156

michael-temp opened this issue Sep 15, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@michael-temp
Copy link

Seems to occur here https://github.com/yoshuawuyts/futures-concurrency/blob/a2a7f6a17ada682e01a0096e0b2a223c886eba39/src/utils/indexer.rs#L20C41-L20C53

attempt to calculate the remainder with a divisor of zero

   0:     0x56172194545c - std::backtrace_rs::backtrace::libunwind::trace::h0533452212810ad0
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x56172194545c - std::backtrace_rs::backtrace::trace_unsynchronized::heac64938397c8c70
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x56172194545c - std::sys_common::backtrace::_print_fmt::hb23dc0a3b2464f20
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x56172194545c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h019008fb57527154
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x56172196edcc - core::fmt::rt::Argument::fmt::hf0ca3042505afdbe
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/core/src/fmt/rt.rs:138:9
   5:     0x56172196edcc - core::fmt::write::h64998bddcdaf5f5a
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/core/src/fmt/mod.rs:1094:21
   6:     0x56172194248e - std::io::Write::write_fmt::hf94b1afaea4dfb0e
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/io/mod.rs:1714:15
   7:     0x561721945244 - std::sys_common::backtrace::_print::hf32e9b06ae985cc8
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x561721945244 - std::sys_common::backtrace::print::h17d3f51425764561
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x561721946ada - std::panicking::panic_hook_with_disk_dump::{{closure}}::hbbc54c0cbf946921
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/panicking.rs:280:22
  10:     0x5617219467d5 - std::panicking::panic_hook_with_disk_dump::h55dfddf51ab4cb86
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/panicking.rs:314:9
  11:     0x5617219470e7 - std::panicking::default_hook::hfb6cc71965100937
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/panicking.rs:239:5
  12:     0x5617219470e7 - std::panicking::rust_panic_with_hook::h0f54142a4d88dc09
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/panicking.rs:753:13
  13:     0x561721946f96 - std::panicking::begin_panic_handler::{{closure}}::ha6353fe00a1ee230
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/panicking.rs:623:13
  14:     0x561721945986 - std::sys_common::backtrace::__rust_end_short_backtrace::h14b2a5ee3b4ff34e
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/sys_common/backtrace.rs:170:18
  15:     0x561721946d22 - rust_begin_unwind
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/panicking.rs:619:5
  16:     0x56172130f2a5 - core::panicking::panic_fmt::had794612bbf3a65e
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/core/src/panicking.rs:72:14
  17:     0x56172130f343 - core::panicking::panic::h130bbbcc8243c26e
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/core/src/panicking.rs:127:5
  18:     0x56172174f867 - core::num::<impl usize>::wrapping_rem::hfea8ea753c74a507
                               at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/core/src/num/mod.rs:1267:5
  19:     0x56172174f867 - futures_concurrency::utils::indexer::Indexer::iter::h355ba57a82748b72
                               at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-concurrency-7.4.2/src/utils/indexer.rs:20:41
  20:     0x56172148fd53 - <futures_concurrency::future::race::vec::Race<Fut> as core::future::future::Future>::poll::h3f8741cf78a1a619
                               at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-concurrency-7.4.2/src/future/race/vec.rs:51:22
  21:     0x56172148fd53 - <futures_time::future::timeout::Timeout<F,D> as core::future::future::Future>::poll::h44e3139b74cfd46f
                               at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-time-3.0.0/src/future/timeout.rs:46:15

Will add more details shortly

@michael-temp
Copy link
Author

My code looks like:

            if let Ok((i, Ok(..))) = notifiers
                .iter_mut()
                .enumerate()
                .map(|(i, notifier)| async move { (i, notifier.receiver.recv().await) })
                .collect_vec()
                .race()
                .timeout(Duration::from_millis(500))
                .await
            {
                has_update[i] = true;
            }

@michael-temp
Copy link
Author

I suspect its an empty vec issue like #153 :)

@michael-temp
Copy link
Author

In case it helps

    #[tokio::test]
    // #[ignore]
    async fn test_race_empty_vec() -> Result<()> {
        // https://github.com/yoshuawuyts/futures-concurrency/issues/156

        _ = Vec::<AbortOnDrop<()>>::new().race().timeout(DurationF::from_millis(500)).await;

        Ok(())
    }

@yoshuawuyts
Copy link
Owner

yoshuawuyts commented Sep 22, 2023

Thanks for reporting this! I wasn't aware of this behavior. I've filed a bug against rustc to document that this method may in fact panic here: rust-lang/rust#116063. I'll work on a fix in our code here for this next.

@yoshuawuyts yoshuawuyts self-assigned this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants