Skip to content

internal error: entered unreachable code: reader indicated readiness but then returned pending #13

Description

@joshbenz

Hello all, this is a neat crate and LOVE the nom crate. I am considering using this crate in conjunction with https://crates.io/crates/async-ssh2-lite crate. I have an AsyncStream<tokio::net::TcpStream> and I get the following error.

thread 'main' panicked at 'internal error: entered unreachable code: reader indicated readiness but then returned pending', /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.24/src/io/fill_buf.rs:41:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
   2: core::panicking::unreachable_display
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:63:5
   3: <futures_util::io::fill_buf::FillBuf<R> as core::future::future::Future>::poll
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.24/src/io/fill_buf.rs:41:21
   4: <nom_bufreader::async_bufreader::BufReader<R> as nom_bufreader::AsyncParse<O,E,P>>::parse::{{closure}}
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-bufreader-0.2.0/src/lib.rs:266:36
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/future/mod.rs:91:19
   6: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/future/future.rs:124:9
   7: flicli::channel::ChannelReader::read::{{closure}}
             at ./src/channel.rs:54:48
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/future/mod.rs:91:19
   9: flicli::main::{{closure}}
             at ./src/main.rs:18:35
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/future/mod.rs:91:19
  11: tokio::park::thread::CachedParkThread::block_on::{{closure}}
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/park/thread.rs:267:54
  12: tokio::coop::with_budget::{{closure}}
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/coop.rs:102:9
  13: std::thread::local::LocalKey<T>::try_with
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/local.rs:445:16
  14: std::thread::local::LocalKey<T>::with
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/local.rs:421:9
  15: tokio::coop::with_budget
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/coop.rs:95:5
  16: tokio::coop::budget
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/coop.rs:72:5
  17: tokio::park::thread::CachedParkThread::block_on
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/park/thread.rs:267:31
  18: tokio::runtime::enter::Enter::block_on
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/runtime/enter.rs:152:13
  19: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/runtime/scheduler/multi_thread/mod.rs:79:9
  20: tokio::runtime::Runtime::block_on
             at /home/jbenz/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.0/src/runtime/mod.rs:492:44
  21: flicli::main
             at ./src/main.rs:19:5
  22: core::ops::function::FnOnce::call_once
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The code I am trying to work with is

                let mut chan = sess.channel_session().await?;
                chan.request_pty("xterm", None, Some((80, 24, 0, 0))).await?;
                chan.shell().await?;
                stdin = chan.stream(0);
                stdout = chan.stream(0);
                stdin.write(b"environment no more\nfile dir\n").await?;
                stdin.flush().await?;
                let mut reader = BufReader::new(stdout.compat);
                let m = reader.parse(Self::method).await;

Sometimes the code runs successfully, but mostly it fails with the above error. I am unsure of if this is due to using AsyncStream (which does implement futures::AsyncRead) or if this is an issue with this crate. It's not a big deal if what I am trying to do is not possible, i will just go a different direction with my code, but I thought I would bring it up anyways.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions