whisperfish/presage

Panic after resetting session mid conversation

Closed this issue · 5 comments

I am using the presage library in a very similar manner to the CLI "receive" command, and while actively receiving messages, if I hit "Reset session" in Signal Desktop, the following will occur:

[INFO  libsignal_protocol::state::session] Skipping archive, current session state is fresh
[INFO  libsignal_protocol::session_cipher] XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.2 creating new chains.
thread 'main' panicked at 'tx channel error: SendError { kind: Disconnected }', /home/user/.cargo/git/checkouts/presage-6024bc59a812fbaf/8c6476f/src/manager.rs:630:62
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/option.rs:1300:5
   3: core::result::Result<T,E>::expect
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/result.rs:997:23
   4: presage::manager::Manager<C,R>::receive_messages::{{closure}}
             at /home/user/.cargo/git/checkouts/presage-6024bc59a812fbaf/8c6476f/src/manager.rs:630:30
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/future/mod.rs:80:19
   6: <futures_util::future::maybe_done::MaybeDone<Fut> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.14/src/future/maybe_done.rs:95:38
   7: <futures_util::future::join::Join<Fut1,Fut2> as core::future::future::Future>::poll
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.14/src/future/join.rs:55:33
   8: test2::on_message::{{closure}}
             at ./src/main.rs:54:9
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/future/mod.rs:80:19
  10: test2::main::{{closure}}
             at ./src/main.rs:30:5
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/future/mod.rs:80:19
  12: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/future/future.rs:119:9
  13: tokio::runtime::basic_scheduler::Inner<P>::block_on::{{closure}}::{{closure}}
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/basic_scheduler.rs:213:62
  14: tokio::coop::with_budget::{{closure}}
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/coop.rs:106:9
  15: std::thread::local::LocalKey<T>::try_with
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:272:16
  16: std::thread::local::LocalKey<T>::with
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:248:9
  17: tokio::coop::with_budget
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/coop.rs:99:5
  18: tokio::coop::budget
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/coop.rs:76:5
  19: tokio::runtime::basic_scheduler::Inner<P>::block_on::{{closure}}
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/basic_scheduler.rs:213:39
  20: tokio::runtime::basic_scheduler::enter::{{closure}}
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/basic_scheduler.rs:323:29
  21: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/macros/scoped_tls.rs:61:9
  22: tokio::runtime::basic_scheduler::enter
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/basic_scheduler.rs:323:5
  23: tokio::runtime::basic_scheduler::Inner<P>::block_on
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/basic_scheduler.rs:202:9
  24: tokio::runtime::basic_scheduler::InnerGuard<P>::block_on
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/basic_scheduler.rs:481:9
  25: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/basic_scheduler.rs:162:24
  26: tokio::runtime::Runtime::block_on
             at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/mod.rs:450:46
  27: test2::main
             at ./src/main.rs:11:1
  28: core::ops::function::FnOnce::call_once
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:227:5

Please try receive_messages_stream instead, which gives you a stream. This stream will stop whenever you reset the session.

@boxdot just updated my code to use this method, and it no longer panics! However, I am not sure if this issue should still remain open to keep track of this panic, so I'll leave that up to you.

@lushing Thanks, most likely we want to remove the panicking method.
@gferon What do you think?

Sure, let's remove it! Can you maybe send a PR for that @boxdot?

@lushing After #28 is merged, please replace receive_messages_stream by receive_messages.