Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PtySession::expect_eof never finishes with current nightly build #38

Closed
Jonathas-Conceicao opened this issue Aug 19, 2021 · 4 comments
Closed

Comments

@Jonathas-Conceicao
Copy link

Jonathas-Conceicao commented Aug 19, 2021

I've traced down the source of a faulty execution in a application that I contribute to the PtySession::expect_eof never finishing execution on Rut's currently nightly build.

I have a little example that can reproduce the problem:

// On Cargo.toml
// [dependencies]
// rexpect = "0.4"

fn main() {
    let mut p = rexpect::spawn("echo 'working as expected'", Some(10000)).unwrap();
    println!("{}", p.exp_eof().unwrap());
}

When I run this on nightly the timeout is reached, and if no timeout is set the execution just hangs indefinitely. On stable it just works as expected.

Here's my rust and cargo version for the nightly build:

$ rustc --version --verbose
rustc 1.56.0-nightly (30a0a9b69 2021-08-17)
binary: rustc
commit-hash: 30a0a9b694cde95cbab863f7ef4d554f0f46b606
commit-date: 2021-08-17
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

$ cargo --version --verbose
cargo 1.56.0-nightly (b51439fd8 2021-08-09)
release: 1.56.0
commit-hash: b51439fd8b505d4800a257acfecf3c69f81e35cf
commit-date: 2021-08-09

Would appreciate if you guys could make it compatible with nightly again as it is what I use during development. In the mean time I'll be pining down my nightly to the last working release.

@Jonathas-Conceicao
Copy link
Author

From what I've tested, error started from nightly-2021-07-03 onward.

@zhiburt
Copy link
Contributor

zhiburt commented Aug 27, 2021

Good catch @Jonathas-Conceicao.
The issue most likely here

https://github.com/philippkeller/rexpect/blob/db3b17d33af0db39134d82010f0e848a2b404769/src/reader.rs#L171-L172

I have a guess after a short investigation and as I was facing something as strange in the nearest.

ref: zhiburt/ptyprocess#7

Essentially they introduce a new type of io::Error on nightly.


@philippkeller I hope you don't mind if I refer to expectrl here

Note: Just tested expectrl against this issue and master branch works.

[dependencies]
expectrl = {git = "https://github.com/zhiburt/expectrl"}
use expectrl::Eof;

fn main() {
    let mut p = expectrl::spawn("echo 'working as expected'").unwrap();
    println!("{:?}", String::from_utf8_lossy(p.expect(Eof).unwrap().found_match()));
}
[mzhiburt@fedora exampleexpectrl]$ cargo run
   Compiling exampleexpectrl v0.1.0 (/home/mzhiburt/projects/exampleexpectrl)
    Finished dev [unoptimized + debuginfo] target(s) in 1.47s
     Running `target/debug/exampleexpectrl`
"'working as expected'\r\n"
[mzhiburt@fedora exampleexpectrl]$ cargo --version --verbose
cargo 1.56.0-nightly (e96bdb0c3 2021-08-17)
release: 1.56.0
commit-hash: e96bdb0c3d0a418e7fcd7fbd69be08abf830b4bc
commit-date: 2021-08-17

@philippkeller
Copy link
Collaborator

@zhiburt thanks for stepping in and I have absolutely nothing against promoting your repo - as I currently have not time maintaining this

@ekarlsn
Copy link
Collaborator

ekarlsn commented Sep 17, 2022

Closed with #40

@ekarlsn ekarlsn closed this as completed Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants