`Conversation::send_message` errors with "tried to use an ended Conversation"
Summary
Calling Conversation::send_message
returns the error: "tried to use an ended Conversation".
Steps to reproduce:
use arti_client::config::TorClientConfigBuilder;
use arti_client::TorClient;
#[tokio::main]
async fn main() -> arti_client::Result<()> {
let builder = TorClientConfigBuilder::default();
let tor_client = TorClient::create_bootstrapped(builder.build().unwrap()).await?;
let connection = tor_client.connect(("example.com", 80)).await?;
struct Conversation;
impl tor_proto::circuit::MsgHandler for Conversation {
fn handle_msg(
&mut self,
_conversation: tor_proto::circuit::ConversationInHandler<'_, '_, '_>,
_msg: tor_cell::relaycell::msg::AnyRelayMsg,
) -> tor_proto::Result<tor_proto::circuit::MetaCellDisposition> {
Ok(tor_proto::circuit::MetaCellDisposition::Consumed)
}
}
let circuit = connection.circuit();
let cell =
tor_cell::relaycell::msg::AnyRelayMsg::Drop(tor_cell::relaycell::msg::Drop::default());
let last_hop = circuit.last_hop_num().unwrap();
let conversation = circuit
.start_conversation(None, Conversation, last_hop)
.await
.unwrap();
conversation.send_message(cell).await.unwrap();
Ok(())
}
[package]
name = "arti-send-message"
version = "0.1.0"
edition = "2021"
[dependencies]
arti-client = { version = "0.10.2", features = ["static"] }
tokio = { version = "1", features = ["macros", "rt"] }
tor-cell = { version = "*" }
tor-proto = { version = "*" , features = ["experimental-api", "send-control-msg"] }
What is the current bug behavior?
thread 'main' panicked at src/main.rs:34:43:
called `Result::unwrap()` on an `Err` value: Bug(Bug(BugRepr { message: "tried to use an ended Conversation", location: Location { file: "/home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-proto-0.12.2/src/circuit/reactor.rs", line: 1485, col: 44 }, backtrace: Captured( 0: tor_error::internal::ie_backtrace::capture
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-error-0.5.4/src/internal.rs:23:18
1: tor_error::internal::Bug::new_inner
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-error-0.5.4/src/internal.rs:107:24
2: tor_error::internal::Bug::new
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-error-0.5.4/src/internal.rs:96:9
3: tor_proto::circuit::reactor::Reactor::handle_control::{{closure}}::{{closure}}
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-proto-0.12.2/src/circuit/reactor.rs:1485:44
4: core::option::Option<T>::ok_or_else
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/option.rs:1239:25
5: tor_proto::circuit::reactor::Reactor::handle_control::{{closure}}
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-proto-0.12.2/src/circuit/reactor.rs:1483:39
6: tor_proto::circuit::reactor::Reactor::handle_control
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-proto-0.12.2/src/circuit/reactor.rs:1481:43
7: tor_proto::circuit::reactor::Reactor::run_once::{{closure}}::{{closure}}
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-proto-0.12.2/src/circuit/reactor.rs:723:25
8: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.29/src/future/poll_fn.rs:56:9
9: tor_proto::circuit::reactor::Reactor::run_once::{{closure}}
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-proto-0.12.2/src/circuit/reactor.rs:854:13
10: tor_proto::circuit::reactor::Reactor::run::{{closure}}
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-proto-0.12.2/src/circuit/reactor.rs:691:35
11: tor_circmgr::build::create_common::{{closure}}::{{closure}}
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tor-circmgr-0.11.0/src/build.rs:111:31
12: <futures_task::future_obj::LocalFutureObj<T> as core::future::future::Future>::poll
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-task-0.3.29/src/future_obj.rs:84:18
13: <futures_task::future_obj::FutureObj<T> as core::future::future::Future>::poll
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-task-0.3.29/src/future_obj.rs:127:9
14: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
at /home/steve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/core.rs:328:17
...
The docs for send_message()
say "Responses are handled by the MsgHandler
set up when the Conversation
was created", so I would have expected this to work. But send_message()
calls send_internal()
with handler = None
, which queues a CtrlMsg::SendMsgAndInstallHandler
message with handler = None
, and eventually handle_control()
calls:
let handler = handler
.as_ref()
.ok_or_else(|| internal!("tried to use an ended Conversation"))?;
on a None
handler.
What is the expected behavior?
Sends the relay{drop} cell.
Environment
arti-send-message v0.1.0 (/arti-send-message)
├── arti-client v0.10.2
│ ├── cfg-if v1.0.0
│ ├── derive_builder_fork_arti v0.11.2
│ ├── derive_more v0.99.17 (proc-macro)
│ │ [build-dependencies]
│ ├── directories v5.0.1
│ ├── educe v0.4.23 (proc-macro)
│ ├── fs-mistrust v0.7.4
│ ├── futures v0.3.29
│ ├── hostname-validator v1.1.1
│ ├── humantime-serde v1.1.1
│ ├── libc v0.2.149
│ ├── pin-project v1.1.3
│ ├── postage v0.5.0
│ ├── safelog v0.3.4
│ ├── serde v1.0.190
│ ├── thiserror v1.0.50
│ ├── tor-async-utils v0.1.4
│ ├── tor-basic-utils v0.7.4
│ ├── tor-cell v0.12.3
│ ├── tor-chanmgr v0.10.1
│ ├── tor-checkable v0.5.5
│ ├── tor-circmgr v0.11.0
│ ├── tor-config v0.9.5
│ ├── tor-dirmgr v0.11.2
│ ├── tor-error v0.5.4
│ ├── tor-guardmgr v0.10.2
│ ├── tor-keymgr v0.3.0
│ ├── tor-linkspec v0.8.3
│ ├── tor-llcrypto v0.5.5
│ ├── tor-netdir v0.9.5
│ ├── tor-netdoc v0.9.0
│ ├── tor-persist v0.7.4
│ ├── tor-proto v0.12.2
│ ├── tor-rtcompat v0.9.5
│ ├── tracing v0.1.40
│ └── void v1.0.2
├── tokio v1.33.0
│ ├── bytes v1.5.0
│ ├── libc v0.2.149
│ ├── mio v0.8.9
│ ├── num_cpus v1.16.0
│ ├── pin-project-lite v0.2.13
│ ├── signal-hook-registry v1.4.1
│ ├── socket2 v0.5.5
│ └── tokio-macros v2.1.0 (proc-macro)
├── tor-cell v0.12.3 (*)
└── tor-proto v0.12.2 (*)
Edited by opara