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

Crash when searching for a value #294

Closed
vsajip opened this issue Oct 22, 2019 · 3 comments · Fixed by #296
Closed

Crash when searching for a value #294

vsajip opened this issue Oct 22, 2019 · 3 comments · Fixed by #296

Comments

@vsajip
Copy link
Contributor

vsajip commented Oct 22, 2019

This code:

fn main() {
    use std::io::{stdin, stdout, Write};

    use rustyline::error::ReadlineError;
    use rustyline::Editor;

    loop {
        let mut editor = Editor::<()>::new();
        if editor.load_history("history.log").is_err() {
        }
        let result = editor.readline("Enter expression (ctrl-C to quit): ");
        match result {
            Ok(mut line) => {
                editor.add_history_entry(line.as_str());
                line = line.trim().to_string();
                if line.len() > 0 {
                    println!("You entered: {}", line);
                }
            },
            Err(ReadlineError::Interrupted) => {
                break
            },
            Err(ReadlineError::Eof) => {
            },
            Err(err) => {
                println!("Error: {:?}", err);
                break
            }
        }
        editor.save_history("history.log").unwrap();
    }
}

Fails when run if you do a ctrl-R to search for a previous value (which is found). The failure enters when you press Enter on the found value. Console listing with backtrace (Ubuntu-x64, rust 1.38.0):

$ RUST_BACKTRACE=full target/debug/expr_repl
Enter expression (ctrl-C to quit): abc
You entered: abc
(reverse-i-search)`ab': abc           thread 'main' panicked at 'assertion failed: self.layout.cursor <= self.layout.end', /home/vinay/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-5.0.3/src/edit.rs:125:13
stack backtrace:
   0:     0x5565d5ee898b - backtrace::backtrace::libunwind::trace::h89fcc71e59e3bc5b
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1:     0x5565d5ee898b - backtrace::backtrace::trace_unsynchronized::h0bad9be1379e729a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2:     0x5565d5ee898b - std::sys_common::backtrace::_print::hd3382a1f33c473da
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x5565d5ee898b - std::sys_common::backtrace::print::h0ec6f03cfb8e76a6
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x5565d5ee898b - std::panicking::default_hook::{{closure}}::h96cbf7b454e3f557
                               at src/libstd/panicking.rs:200
   5:     0x5565d5ee8666 - std::panicking::default_hook::h95a8f00337383d83
                               at src/libstd/panicking.rs:214
   6:     0x5565d5ee909d - std::panicking::rust_panic_with_hook::h92f98b46e22f14ed
                               at src/libstd/panicking.rs:477
   7:     0x5565d5ed3df5 - std::panicking::begin_panic::h96738e055e5f4d65
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/panicking.rs:411
   8:     0x5565d5e678ec - rustyline::edit::State<H>::move_cursor::hdcb71b31d457715f
                               at /home/vinay/projects/rsconfig/<::std::macros::panic macros>:3
   9:     0x5565d5e67e05 - rustyline::edit::State<H>::edit_move_end::hf8b47e6f67dc66dc
                               at /home/vinay/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-5.0.3/src/edit.rs:406
  10:     0x5565d5e5be9d - rustyline::readline_edit::ha6e91a48dad7739e
                               at /home/vinay/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-5.0.3/src/lib.rs:529
  11:     0x5565d5e55950 - rustyline::readline_raw::h8d10993a62be80cd
                               at /home/vinay/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-5.0.3/src/lib.rs:626
  12:     0x5565d5e5f2c2 - rustyline::Editor<H>::readline_with::h243448f87a7c18a2
                               at /home/vinay/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-5.0.3/src/lib.rs:755
  13:     0x5565d5e5f5ad - rustyline::Editor<H>::readline::h0d20b4b1450ecb3c
                               at /home/vinay/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-5.0.3/src/lib.rs:731
  14:     0x5565d5e62d19 - expr_repl::main::ha34c1f1010ec7764
                               at src/bin/expr_repl.rs:31
  15:     0x5565d5e72ab0 - std::rt::lang_start::{{closure}}::h39369991cd93ebad
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  16:     0x5565d5ee8aa3 - std::rt::lang_start_internal::{{closure}}::h4e93c1949c7a1955
                               at src/libstd/rt.rs:49
  17:     0x5565d5ee8aa3 - std::panicking::try::do_call::h9440ccd4dc467eaa
                               at src/libstd/panicking.rs:296
  18:     0x5565d5eeaaba - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  19:     0x5565d5ee95ad - std::panicking::try::hc046e7ee42ee744f
                               at src/libstd/panicking.rs:275
  20:     0x5565d5ee95ad - std::panic::catch_unwind::h27dfc457c200aee0
                               at src/libstd/panic.rs:394
  21:     0x5565d5ee95ad - std::rt::lang_start_internal::hea1b49a567afe309
                               at src/libstd/rt.rs:48
  22:     0x5565d5e72a89 - std::rt::lang_start::hbc1f50dfdb872b3d
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  23:     0x5565d5e6328a - main
  24:     0x7f4952b44b97 - __libc_start_main
  25:     0x5565d5e520da - _start
  26:                0x0 - <unknown>
@gwenn
Copy link
Collaborator

gwenn commented Oct 22, 2019

Thanks you for the detailed bug report

@vsajip
Copy link
Contributor Author

vsajip commented Oct 22, 2019

#296 fixes the issue for me. Thanks!

@gwenn
Copy link
Collaborator

gwenn commented Oct 30, 2019

Fixed by release 5.0.4

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.

2 participants