Skip to content

Tiny panicks when connecting to irc.gitter.im #211

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

Closed
Kabouik opened this issue Jun 18, 2020 · 15 comments
Closed

Tiny panicks when connecting to irc.gitter.im #211

Kabouik opened this issue Jun 18, 2020 · 15 comments

Comments

@Kabouik
Copy link

Kabouik commented Jun 18, 2020

Maybe I didn't configure it correctly, but if so I couldn't find what parameter is wrong and causing this issue:

thread 'main' panicked at 'byte index 13 is out of bounds of ` 1.10.0`', /rust/47c3158c3d797f75f0f7b2b2a977179668919dab/src/libcore/str/mod.rs:2052:47
    - addr: irc.gitter.im
      port: 6697
      tls: true
      realname: Kabouik
      nicks: [Kabouik]

      # (optional) Server alias for display in tab line
      alias: Gitter

      # Channels to automatically join
      join:
          - '#jarun/nnn'

      # Server or nick password
      pass: 'mytoken'

I tried with or without nicknames listed in nicks, with or without the channel, but no difference.

I followed instructions at https://irc.gitter.im/.

@osa1
Copy link
Owner

osa1 commented Jun 18, 2020

Thanks for reporting. Could you run tiny again with this command and paste the contents of file stderr ?

$ RUST_BACKTRACE=1 tiny 2>stderr

It'd be even more helpful if you could try this with a debug build, e.g. build tiny as described in README, then in the same directory

$ RUST_BACKTRACE=1 target/debug/tiny 2>stderr

@Kabouik
Copy link
Author

Kabouik commented Jun 18, 2020

I'll try with a debug build later, but in the meantime, here is the backtrace with the normal build, in case it helps:

thread 'main' panicked at 'byte index 13 is out of bounds of ` 1.10.0`', /rustc/47c3158c3d797f75f0f7b2b2a977179668919dab/src/libcore/str/mod.rs:2052:47                                                                                        
stack backtrace:                                                                                                                                                                                                                               
   0: backtrace::backtrace::libunwind::trace                                                                                                                                                                                                   
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86                                                                                                                                 
   1: backtrace::backtrace::trace_unsynchronized                                                                                                                                                                                               
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66                                                                                                                                       
   2: std::sys_common::backtrace::_print_fmt                                                                                                                                                                                                   
             at src/libstd/sys_common/backtrace.rs:78                                                                                                                                                                                          
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt                                                                                                                                                        
             at src/libstd/sys_common/backtrace.rs:59                                                                                                                                                                                          
   4: core::fmt::write                                                                                                                                                                                                                         
             at src/libcore/fmt/mod.rs:1076                                                                                                                                                                                                    
   5: std::io::Write::write_fmt                                                                                                                                                                                                                
             at src/libstd/io/mod.rs:1537                                                                                                                                                                                                      
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:486
  11: rust_begin_unwind
             at src/libstd/panicking.rs:388
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:101
  13: core::str::slice_error_fail
             at src/libcore/str/mod.rs:0
  14: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeFrom<usize>>::index::{{closure}} 
  15: libtiny_client::state::StateInner::update
  16: libtiny_client::main_loop::{{closure}}
  17: tokio::runtime::task::raw::poll
  18: tokio::task::local::LocalSet::tick
  19: std::thread::local::LocalKey<T>::with
  20: tokio::runtime::handle::Handle::enter
  21: tiny::main
  22: std::rt::lang_start_internal::{{closure}}::{{closure}}
             at src/libstd/rt.rs:52
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Closed(Msg("JOIN #jarun/nnn\r\n"))', libtiny_client/src/lib.rs:216:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:486
  11: rust_begin_unwind
             at src/libstd/panicking.rs:388
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:101
  13: core::option::expect_none_failed
             at src/libcore/option.rs:1272
  14: tiny::cmd::join
  15: std::thread::local::LocalKey<T>::with
  16: std::thread::local::LocalKey<T>::with
  17: tokio::runtime::handle::Handle::enter
  18: tiny::main
  19: std::rt::lang_start_internal::{{closure}}::{{closure}}
             at src/libstd/rt.rs:52
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@osa1
Copy link
Owner

osa1 commented Jun 19, 2020

I can reproduce this locally.

First of all here's a problem with tiny that is not specific to this bug: in case of a panic in a task we should really abort. I don't know how tiny can continue operating after a panic (after all, we don't spawn any threads, and AFAIK you can only catch panics in thread boundaries), but it clearly can, as otherwise there would be at most one panic reported in stderr in a panic.

Currently I get three panics, I think only the first one is relevant (others are chain reaction) so only pasting that:

Backtrace
thread 'main' panicked at 'byte index 13 is out of bounds of ` 1.10.0`', /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/str/mod.rs:2052:47
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  11: rust_begin_unwind
             at src/libstd/panicking.rs:385
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:86
  13: core::str::slice_error_fail
             at src/libcore/str/mod.rs:0
  14: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeFrom<usize>>::index::{{closure}}
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/str/mod.rs:2052
  15: core::option::Option<T>::unwrap_or_else
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:430
  16: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeFrom<usize>>::index
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/str/mod.rs:2052
  17: core::str::traits::<impl core::ops::index::Index<I> for str>::index
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/str/mod.rs:1780
  18: <alloc::string::String as core::ops::index::Index<core::ops::range::RangeFrom<usize>>>::index
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/string.rs:2076
  19: libtiny_client::state::parse_servername
             at libtiny_client/src/state.rs:503
  20: libtiny_client::state::StateInner::update
             at libtiny_client/src/state.rs:324
  21: libtiny_client::state::State::update
             at libtiny_client/src/state.rs:39
  22: libtiny_client::main_loop::{{closure}}
             at libtiny_client/src/lib.rs:448
  23: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:73
  24: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/core.rs:173
  25: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/loom/std/unsafe_cell.rs:14
  26: tokio::runtime::task::core::Core<T,S>::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/core.rs:158
  27: tokio::runtime::task::harness::Harness<T,S>::poll::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/harness.rs:107
  28: core::ops::function::FnOnce::call_once
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:232
  29: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:318
  30: std::panicking::try::do_call
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:297
  31: __rust_try
  32: std::panicking::try
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:274
  33: std::panic::catch_unwind
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:394
  34: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/harness.rs:89
  35: tokio::runtime::task::raw::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/raw.rs:104
  36: tokio::runtime::task::raw::RawTask::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/raw.rs:66
  37: tokio::runtime::task::Notified<S>::run
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/mod.rs:169
  38: tokio::task::local::LocalSet::tick::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:406
  39: tokio::coop::with_budget::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:127
  40: std::thread::local::LocalKey<T>::try_with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:263
  41: std::thread::local::LocalKey<T>::with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:239
  42: tokio::coop::with_budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:120
  43: tokio::coop::budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:96
  44: tokio::task::local::LocalSet::tick
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:406
  45: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:530
  46: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/macros/scoped_tls.rs:63
  47: tokio::task::local::LocalSet::with
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:440
  48: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:516
  49: tokio::task::local::LocalSet::run_until::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:390
  50: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:73
  51: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:131
  52: tokio::coop::with_budget::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:127
  53: std::thread::local::LocalKey<T>::try_with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:263
  54: std::thread::local::LocalKey<T>::with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:239
  55: tokio::coop::with_budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:120
  56: tokio::coop::budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:96
  57: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:131
  58: tokio::runtime::basic_scheduler::enter::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:213
  59: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/macros/scoped_tls.rs:63
  60: tokio::runtime::basic_scheduler::enter
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:213
  61: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:123
  62: tokio::runtime::Runtime::block_on::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/mod.rs:444
  63: tokio::runtime::context::enter
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/context.rs:72
  64: tokio::runtime::handle::Handle::enter
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/handle.rs:76
  65: tokio::runtime::Runtime::block_on
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/mod.rs:441
  66: tokio::task::local::LocalSet::block_on
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:351
  67: tiny::run
             at tiny/src/main.rs:103
  68: tiny::main
             at tiny/src/main.rs:65
  69: std::rt::lang_start::{{closure}}
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  70: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  71: std::panicking::try::do_call
             at src/libstd/panicking.rs:297
  72: std::panicking::try
             at src/libstd/panicking.rs:274
  73: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  74: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  75: std::rt::lang_start
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  76: main
  77: __libc_start_main
  78: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The bug is in this function:

/// Try to parse servername in a 002 RPL_YOURHOST reply
fn parse_servername(params: &[String]) -> Option<String> {
    let msg = params.get(1).or_else(|| params.get(0))?;
    let slice1 = &msg[13..];
    let servername_ends = slice1.find('[').or_else(|| slice1.find(','))?;
    Some((&slice1[..servername_ends]).to_owned())
}

Here the magic number 13 is the length of string "Your host is ". This assumes that RPL_YOURHOST messages always start with that prefix. This is per RFC 2812, which defines response format as

       002    RPL_YOURHOST
              "Your host is <servername>, running version <ver>"

Apparently this server doesn't follow this format.

The function parse_servername is very fragile and we should make sure to check all bounds here. I'll update the code.

Reminder: the server name parsed in this function is used when pinging the server when we don't hear from it for a while. If we can't parse server name of a server then send_ping simply returns.

@osa1
Copy link
Owner

osa1 commented Jun 19, 2020

The full 002 message from this server (excluding the prefix) is this:

002 osa1 Version: 1.10.0

This doesn't have a server name so I don't know how to ping this server. I guess we won't ping it for now. Though I now realize that if we never ping we may incorrectly think that the connection has timed out and reconnect. Pings are how we currently check connectivity when we don't hear from a server for a while.

osa1 added a commit that referenced this issue Jun 19, 2020
Per RFC 2812, reply 002 should look like

    Your host is <servername>, running version <ver>

But this doesn't hold for some servers, see #211.
@osa1
Copy link
Owner

osa1 commented Jun 19, 2020

I just pushed a commit, parse_servername now never fails as the array indexing is properly guarded now. Next up is this assertion failure:

Assertion failure
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `3`,
 right: `2`', tiny/src/conn.rs:364:17
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  11: rust_begin_unwind
             at src/libstd/panicking.rs:385
  12: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:339
  13: tiny::conn::handle_irc_msg
             at tiny/src/conn.rs:364
  14: tiny::conn::handle_conn_ev
             at tiny/src/conn.rs:103
  15: tiny::conn::task::{{closure}}
             at tiny/src/conn.rs:18
  16: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:73
  17: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/core.rs:173
  18: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/loom/std/unsafe_cell.rs:14
  19: tokio::runtime::task::core::Core<T,S>::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/core.rs:158
  20: tokio::runtime::task::harness::Harness<T,S>::poll::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/harness.rs:107
  21: core::ops::function::FnOnce::call_once
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:232
  22: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:318
  23: std::panicking::try::do_call
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:297
  24: __rust_try
  25: std::panicking::try
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:274
  26: std::panic::catch_unwind
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:394
  27: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/harness.rs:89
  28: tokio::runtime::task::raw::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/raw.rs:104
  29: tokio::runtime::task::raw::RawTask::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/raw.rs:66
  30: tokio::runtime::task::Notified<S>::run
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/task/mod.rs:169
  31: tokio::task::local::LocalSet::tick::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:406
  32: tokio::coop::with_budget::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:127
  33: std::thread::local::LocalKey<T>::try_with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:263
  34: std::thread::local::LocalKey<T>::with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:239
  35: tokio::coop::with_budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:120
  36: tokio::coop::budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:96
  37: tokio::task::local::LocalSet::tick
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:406
  38: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:530
  39: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/macros/scoped_tls.rs:63
  40: tokio::task::local::LocalSet::with
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:440
  41: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:516
  42: tokio::task::local::LocalSet::run_until::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:390
  43: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:73
  44: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:131
  45: tokio::coop::with_budget::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:127
  46: std::thread::local::LocalKey<T>::try_with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:263
  47: std::thread::local::LocalKey<T>::with
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/thread/local.rs:239
  48: tokio::coop::with_budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:120
  49: tokio::coop::budget
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/coop.rs:96
  50: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:131
  51: tokio::runtime::basic_scheduler::enter::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:213
  52: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/macros/scoped_tls.rs:63
  53: tokio::runtime::basic_scheduler::enter
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:213
  54: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/basic_scheduler.rs:123
  55: tokio::runtime::Runtime::block_on::{{closure}}
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/mod.rs:444
  56: tokio::runtime::context::enter
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/context.rs:72
  57: tokio::runtime::handle::Handle::enter
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/handle.rs:76
  58: tokio::runtime::Runtime::block_on
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/mod.rs:441
  59: tokio::task::local::LocalSet::block_on
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/task/local.rs:351
  60: tiny::run
             at tiny/src/main.rs:103
  61: tiny::main
             at tiny/src/main.rs:65
  62: std::rt::lang_start::{{closure}}
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  63: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  64: std::panicking::try::do_call
             at src/libstd/panicking.rs:297
  65: std::panicking::try
             at src/libstd/panicking.rs:274
  66: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  67: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  68: std::rt::lang_start
             at /home/omer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  69: main
  70: __libc_start_main
  71: _start

@trevarj
Copy link
Contributor

trevarj commented Jun 19, 2020

The params look incorrectly parsed where the debug_assert is panicking.
params["trevarj", "Gitter", "trevarj!trevarj@irc.gitter.im"]

Should be like this I think :
params["trevarj", "Gitter trevarj!trevarj@irc.gitter.im"]

    001    RPL_WELCOME
              "Welcome to the Internet Relay Network
               <nick>!<user>@<host>"

Edit:
@osa1
I think it's because this is the full message that the server sends:
:irc.gitter.im 001 trevarj Gitter :trevarj!trevarj@irc.gitter.im
and then parse_params in libtiny_wire::lib.rsis splitting on that second colon.

To me it seems like this is the server's fault? They should be sending the message like
:irc.gitter.im 001 trevarj :Gitter trevarj!trevarj@irc.gitter.im.
In the examples of RPL_WELCOME messages it appears that this is the acceptable format.

One more edit:
https://gitlab.com/gitlab-org/gitter/irc-bridge/-/blob/develop/lib/gitter-adapter.js#L271

@osa1 osa1 closed this as completed in b6ea12e Jun 20, 2020
@osa1 osa1 reopened this Jun 20, 2020
@osa1
Copy link
Owner

osa1 commented Jun 20, 2020

@trevarj thanks for the investigation. I think you're right that this is the server's fault. In any case, I updated the message handler code now so we now ignore messages that are not in the expected format instead of panicking.

@Kabouik you should be able to connect to this server now. Let me know if you encounter any other problems.

@osa1 osa1 closed this as completed Jun 20, 2020
@Kabouik
Copy link
Author

Kabouik commented Jun 20, 2020

Thanks a lot! I can confirm it now works. There's something that I think is new in the mentions tab though:

Logger error: Os { code: 2, kind: NotFound, message: "No such file or directory" }

Also, I was initially using tiny with native openssl and this time I tried to update with rustls, but I was having panic messages inside the TUI (similar as what I had here when reporting the Gitter issue), and compiling again with native openssl fixed that. I thought it was worth mentioning here since as far as I understand, tiny should no longer report panic messages inside the TUI (plus they actually break the TUI).

@osa1
Copy link
Owner

osa1 commented Jun 20, 2020

So the "Logger error" part is expected: it happens when the logger encounters an IO error during a log operation. In your case it seems like it can't open a file. Did you remove the log directory after starting tiny?

Also, I was initially using tiny with native openssl and this time I tried to update with rustls, but I was having panic messages inside the TUI (similar as what I had here when reporting the Gitter issue), and compiling again with native openssl fixed that

Interesting, I use both libraries and never had any problems. I just tried connecting to irc.gitter.im using rustls and it worked fine. Which server are you trying to connect when you get panic messages?

The story with reporting panics is not great, unfortunately. I've recently opened #212 to fix that.

@Kabouik
Copy link
Author

Kabouik commented Jun 20, 2020

No, the log directory is still here and I didn't touch its permsisions, so I'm not sure what changed.

I compiled tiny with openssl now, I can rebuild with rustls later tonight to further test if you want. In the meantime, here are the servers I'm connecting to: irc.rizon.net, irc.gitter.im, chat.freenode.net, euroserv.fr.quakenet.org, irc.undernet.org. I connected to all when I got the issue so I'm not sure which one caused the panic.

Ok, I saw #212 later indeed!

@Kabouik
Copy link
Author

Kabouik commented Jun 20, 2020

I think the issue might be related to Gitter rooms being formatted with a slash in their name, which must conflict with the way tiny sets filenames for logs. You can see above in my configuration file that the channel I wanted to join on irc.gitter.im was "#jarun/nnn". If this is really the cause, then perhaps an acceptable workaround would be to replace / with another character when creating new log files, such as -?

I built tiny with rustls, the issue is with irc.rizon.net:

oad {
                 level: Fatal,
                                          description: HandshakeFailure,
                                                                                },
                                                                                      ),
[2020-06-20T23:28:19Z] ERROR [/home/mathieu/.cargo/registry/src/github.com-1ecc6299db9ec823/rustls-0.16.0/src/session.rs:571] TLS alert received: Message {
                                          typ: Alert,
                                                         version: TLSv1_2,
                                                                              payload: Alert(
                                                                                                     AlertMessagePayload {
                 level: Fatal,
                                          description: HandshakeFailure,
                                                                                },
                                                                                      ),
[2020-06-20T23:28:19Z] ERROR [/home/mathieu/.cargo/registry/src/github.com-1ecc6299db9ec823/rustls-0.16.0/src/session.rs:571] TLS alert received: Message {
                                          typ: Alert,
                                                         version: TLSv1_2,
                                                                              payload: Alert(
                                                                                                     AlertMessagePayload {
                 level: Fatal,
                                          description: HandshakeFailure,
                                                                                },
                                                                                      ),
                                                                                        }

I couldn't copy everything due to the broken TUI, sorry. However I think it's just the same message repeated several times.

@osa1
Copy link
Owner

osa1 commented Jun 21, 2020

Thanks @Kabouik, I moved the issue with logging to #214.

I'm a bit confused about the TLS error. The lines you pasted seem to be log lines, not panics, right? So you run tiny with RUST_LOG=debug tiny?

Btw, panics and log lines are printed to stderr not stdout, so you can do this to avoid those to break the TUI:

RUST_LOG=debug tiny 2>tiny_logs

Then look at the file tiny_logs for log lines. You can also do tail -f tiny_logs to follow updates on the file.

@osa1
Copy link
Owner

osa1 commented Jun 21, 2020

Confirmed that you can't connect to irc.rizon.net using rustls. I'll open an issue about this.

@Kabouik
Copy link
Author

Kabouik commented Jun 21, 2020

I'm a bit confused about the TLS error. The lines you pasted seem to be log lines, not panics, right? So you run tiny with RUST_LOG=debug tiny?

Btw, panics and log lines are printed to stderr not stdout, so you can do this to avoid those to break the TUI:

RUST_LOG=debug tiny 2>tiny_logs

Then look at the file tiny_logs for log lines. You can also do tail -f tiny_logs to follow updates on the file.

Sorry I didn't see my emails earlier. Do you still need me to do this, or did you check already before opening #215?

@osa1
Copy link
Owner

osa1 commented Jun 21, 2020

No worries -- I already checked that, yes.

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

3 participants