aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
528 stars 97 forks source link

thread 'main' panicked at 'assertion failed: result.is_ready()' #120

Closed ma1ko closed 6 years ago

ma1ko commented 6 years ago

I'm currently developing an IRC bot and regulary hit this assertion after running for a few hours. It often happens when someone is (successfully) trying to DoS my bot. What's going wrong? Do you need more information?

thread 'main' panicked at 'assertion failed: result.is_ready()', /home/maiko/.cargo/registry/src/github.com-1ecc6299db9ec823/irc-0.13.3/src/client/transport.rs:76:8
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::begin_panic
6: <irc::client::transport::IrcTransport<T>>::send_ping
7: <irc::client::conn::Connection as futures::stream::Stream>::poll
8: <irc::client::ClientStream as futures::stream::Stream>::poll
9: <futures::stream::for_each::ForEach<S, F, U> as futures::future::Future>::poll
10: <futures::task_impl::Spawn<T>>::enter::{{closure}}
11: irc::client::reactor::IrcReactor::run
12: <redacted>
13: __rust_maybe_catch_panic
14: std::panicking::try
15: std::rt::lang_start
16: __libc_start_main
17: _start

Thanks for you help and awesome crate!

aatxe commented 6 years ago

Hey, thanks for taking the time to report this! The gist is that it's getting backed up sending messages downstream (presumably because of this DoS attempt), and apparently, at some point, it seemed to me like that wouldn't happen (not sure why, past me was evidently wrong though!) and I put this assertion in place that starting to send a message will always be ready. To fix it, we'll need to change a bit of the send_ping logic (to not update internal state until after start_send has succeeded, at the very least), but it shouldn't be a bad change.

ma1ko commented 6 years ago

Wow, thank you for the fast response! I just re-build my bot with the new release, got DoS'ed again soon and this time the attacker actually gave up