[go: up one dir, main page]

Skip to content

sending fails with `source slice length (0) does not match destination slice length (1)`

hi. been using this lib for some concepts ive been making. looks like send_async has a problem which is:

thread 'tokio-runtime-worker' panicked at /home/roby/.cargo/git/checkouts/mavio-2bc3238cbba0dd8c/c2e26ba/mavio/src/protocol/frame.rs:512:32:
source slice length (0) does not match destination slice length (1)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
   2: core::slice::<impl [T]>::copy_from_slice::len_mismatch_fail
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/slice/mod.rs:3674:13
   3: core::slice::<impl [T]>::copy_from_slice
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/slice/mod.rs:3681:13
   4: mavio::protocol::frame::Frame<V>::fill_body_buffer
             at /home/roby/.cargo/git/checkouts/mavio-2bc3238cbba0dd8c/c2e26ba/mavio/src/protocol/frame.rs:512:9
   5: mavio::protocol::frame::Frame<V>::send_async::{{closure}}
             at /home/roby/.cargo/git/checkouts/mavio-2bc3238cbba0dd8c/c2e26ba/mavio/src/protocol/frame.rs:503:9
   6: mavio::io::async_sender::AsyncSender<W,V>::send::{{closure}}
             at /home/roby/.cargo/git/checkouts/mavio-2bc3238cbba0dd8c/c2e26ba/mavio/src/io/async_sender.rs:66:44
   7: mavio::io::async_connection::AsyncConnection<V>::send::{{closure}}
             at /home/roby/.cargo/git/checkouts/mavio-2bc3238cbba0dd8c/c2e26ba/mavio/src/io/async_connection.rs:47:33
   8: zenoh_plugin_mavlink::mavlink_connection::MAVLinkConnection::handle::{{closure}}::{{closure}}
             at ./zenoh-plugin-mavlink/src/mavlink_connection.rs:74:107
   9: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.40/src/instrument.rs:321:9
  10: zenoh_plugin_mavlink::mavlink_connection::MAVLinkConnection::handle::{{closure}}
             at ./zenoh-plugin-mavlink/src/mavlink_connection.rs:32:5
  11: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:331:17
  12: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/loom/std/unsafe_cell.rs:16:9
  13: tokio::runtime::task::core::Core<T,S>::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:320:13
  14: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:500:19
  15: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panic/unwind_safe.rs:272:9
  16: std::panicking::try::do_call
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
  17: __rust_try
  18: std::panicking::try
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
  19: std::panic::catch_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
  20: tokio::runtime::task::harness::poll_future
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:488:18
  21: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:209:27
  22: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:154:15
  23: tokio::runtime::task::raw::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:271:5
  24: tokio::runtime::task::raw::RawTask::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:201:18
  25: tokio::runtime::task::LocalNotified<S>::run
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/mod.rs:436:9
  26: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:598:13
  27: tokio::runtime::coop::with_budget
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:107:5
  28: tokio::runtime::coop::budget
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:73:5
  29: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:597:9
  30: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:548:24
  31: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:513:21
  32: tokio::runtime::context::scoped::Scoped<T>::set
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/scoped.rs:40:9
  33: tokio::runtime::context::set_scheduler::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context.rs:180:26
  34: std::thread::local::LocalKey<T>::try_with
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/thread/local.rs:283:12
  35: std::thread::local::LocalKey<T>::with
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/thread/local.rs:260:9
  36: tokio::runtime::context::set_scheduler
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context.rs:180:9
  37: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:508:9
  38: tokio::runtime::context::runtime::enter_runtime
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/runtime.rs:65:16
  39: tokio::runtime::scheduler::multi_thread::worker::run
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:500:5
  40: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:466:45
  41: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/task.rs:42:21
  42: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:331:17
  43: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/loom/std/unsafe_cell.rs:16:9
  44: tokio::runtime::task::core::Core<T,S>::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:320:13
  45: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:500:19
  46: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panic/unwind_safe.rs:272:9
  47: std::panicking::try::do_call
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
  48: __rust_try
  49: std::panicking::try
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
  50: std::panic::catch_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
  51: tokio::runtime::task::harness::poll_future
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:488:18
  52: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:209:27
  53: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:154:15
  54: tokio::runtime::task::raw::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:271:5
  55: tokio::runtime::task::raw::RawTask::poll
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:201:18
  56: tokio::runtime::task::UnownedTask<S>::run
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/mod.rs:473:9
  57: tokio::runtime::blocking::pool::Task::run
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/pool.rs:160:9
  58: tokio::runtime::blocking::pool::Inner::run
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/pool.rs:518:17
  59: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /home/roby/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/pool.rs:476:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

im doing a simple send using my fork which implements an AsyncConnection<V: MaybeVersioned>: https://github.com/roby2014/mavio/commit/c2e26ba59aaf1bc73f636b9c9b56d805e5406570

                            debug!("received message (id: {}) from broadcast channel (origin: {})", msg.mav_frame.message_id(), msg.origin);
                            if let Err(e) = connection.send(&msg.mav_frame.try_into_versioned().unwrap()).await {
                                error!("failed to write to mavlink connection {}: {:?}", self.endpoint, e);
                            } else {
                                debug!("forwarded message from broadcast channel to mavlink connection");
                            }