Sqlx/actix giving a handshake error

I use this piece of code to initiate a pooled connection to my MySQL database:

/* MAIN */
#[actix_web::main]
async fn main() -> std::io::Result<()> {
    let conn_str : String = format!("mysql://{user}:{pass}@127.0.0.1:33060/{name}", user="root", pass="toor", name="kaddo");
    //let pool = MySqlPool::connect(&conn_str).await;

    let mysql = MySQL { conn: MySqlPool::connect(&conn_str).await.unwrap(), };

    // start http server
    HttpServer::new(move || {
        App::new()
        .data(mysql.clone())
        .service(web::resource("/").route(web::get().to(index)))
        .service(web::resource("/home").route(web::get().to(index)))
        .service(web::resource("/bestel").route(web::get().to(bestel)))
        .service(web::resource("/faq").route(web::get().to(faq)))
        .service(Files::new("/assets", "./templates/assets").show_files_listing())
    })
    .bind("127.0.0.1:8080")?
    .run()
    .await
}

I use Actix::web::Data so all my functions can use the MySQL-connection. However, I get this runtime error:

   Finished dev [unoptimized + debuginfo] target(s) in 0.33s
     Running `target/debug/kaddo`
thread 'main' panicked at 'assertion failed: self.remaining() >= dst.len()', /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.6/src/buf/buf_impl.rs:246:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Panic in Arbiter thread.

Backtrace:


    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/kaddo`
thread 'main' panicked at 'assertion failed: self.remaining() >= dst.len()', /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.6/src/buf/buf_impl.rs:246:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   2: core::panicking::panic
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:50
   3: bytes::buf::buf_impl::Buf::copy_to_slice
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.6/src/buf/buf_impl.rs:246
   4: bytes::buf::buf_impl::Buf::get_u32_le
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.6/src/buf/buf_impl.rs:427
   5: <sqlx_core::mysql::protocol::connect::handshake::Handshake as sqlx_core::io::decode::Decode>::decode_with
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/mysql/protocol/connect/handshake.rs:29
   6: sqlx_core::mysql::protocol::packet::Packet<bytes::bytes::Bytes>::decode_with
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/mysql/protocol/packet.rs:56
   7: sqlx_core::mysql::protocol::packet::Packet<bytes::bytes::Bytes>::decode
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/mysql/protocol/packet.rs:49
   8: sqlx_core::mysql::connection::establish::<impl sqlx_core::mysql::connection::MySqlConnection>::establish::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/mysql/connection/establish.rs:20
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  10: sqlx_core::mysql::options::connect::<impl sqlx_core::connection::ConnectOptions for sqlx_core::mysql::options::MySqlConnectOptions>::connect::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/mysql/options/connect.rs:17
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  12: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/future.rs:119
  13: <async_std::future::timeout::TimeoutFuture<F> as core::future::future::Future>::poll
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/timeout.rs:64
  14: async_std::future::timeout::timeout::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/timeout.rs:36
  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  16: sqlx_core::pool::inner::SharedPool<DB>::connection::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/pool/inner.rs:226
  17: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  18: sqlx_core::pool::options::init_min_connections::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/pool/options.rs:240
  19: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  20: sqlx_core::pool::options::PoolOptions<DB>::connect_with::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/pool/options.rs:205
  21: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  22: sqlx_core::pool::options::PoolOptions<DB>::connect::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/pool/options.rs:195
  23: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  24: sqlx_core::pool::Pool<DB>::connect::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.4.2/src/pool/mod.rs:223
  25: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  26: kaddo::main::{{closure}}
             at ./src/main.rs:120
  27: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  28: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/task/local.rs:528
  29: tokio::coop::with_budget::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/coop.rs:127
  30: std::thread::local::LocalKey<T>::try_with
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:272
  31: std::thread::local::LocalKey<T>::with
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:248
  32: tokio::coop::with_budget
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/coop.rs:120
  33: tokio::coop::budget
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/coop.rs:96
  34: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/task/local.rs:528
  35: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/macros/scoped_tls.rs:63
  36: tokio::task::local::LocalSet::with
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/task/local.rs:442
  37: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/task/local.rs:518
  38: tokio::task::local::LocalSet::run_until::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/task/local.rs:392
  39: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
  40: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/basic_scheduler.rs:131
  41: tokio::coop::with_budget::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/coop.rs:127
  42: std::thread::local::LocalKey<T>::try_with
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:272
  43: std::thread::local::LocalKey<T>::with
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:248
  44: tokio::coop::with_budget
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/coop.rs:120
  45: tokio::coop::budget
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/coop.rs:96
  46: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/basic_scheduler.rs:131
  47: tokio::runtime::basic_scheduler::enter::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/basic_scheduler.rs:213
  48: tokio::macros::scoped_tls::ScopedKey<T>::set
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/macros/scoped_tls.rs:63
  49: tokio::runtime::basic_scheduler::enter
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/basic_scheduler.rs:213
  50: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/basic_scheduler.rs:123
  51: tokio::runtime::Runtime::block_on::{{closure}}
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/mod.rs:444
  52: tokio::runtime::context::enter
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/context.rs:72
  53: tokio::runtime::handle::Handle::enter
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/handle.rs:76
  54: tokio::runtime::Runtime::block_on
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/mod.rs:441
  55: tokio::task::local::LocalSet::block_on
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/task/local.rs:353
  56: actix_rt::runtime::Runtime::block_on
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-1.1.1/src/runtime.rs:89
  57: actix_rt::builder::SystemRunner::block_on
             at /Users/niel/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-1.1.1/src/builder.rs:187
  58: kaddo::main
             at ./src/main.rs:115
  59: core::ops::function::FnOnce::call_once
             at /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic in Arbiter thread.

It looks like there's some kind of internal buffer overflow going on which is caught by a bounds check during the connection handshake. Can someone give me info on how to fix this?

Thanks.

This seems like a bug. I would report it to sqlx.

1 Like