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

Nondeterministic results for --convert-repetitions #9

Closed
Mrmaxmeier opened this issue Jan 12, 2020 · 1 comment
Closed

Nondeterministic results for --convert-repetitions #9

Mrmaxmeier opened this issue Jan 12, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@Mrmaxmeier
Copy link

$ git describe
v0.3.1
$ ./target/debug/grex -r "AAAAAA"
^A{6}$
$ ./target/debug/grex -r "AAAAAA"
thread 'main' panicked at 'assertion failed: end <= len', <::core::macros::panic macros>:3:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
$ ./target/debug/grex -r "AAAAAA"
thread 'main' panicked at 'assertion failed: end <= len', <::core::macros::panic macros>:3:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
$ ./target/debug/grex -r "AAAAAA"
^A{6}$
$ ./target/debug/grex -r "AAAAAA"
^(AA){4}A$
$ ./target/debug/grex -r "AAAAAA"
^(AAA){2}$
backtrace for reference

⋊> ~/_/_/grex $ ./target/debug/grex -r "AAAAAA"
thread 'main' panicked at 'assertion failed: end <= len', <::core::macros::panic macros>:3:10
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1057
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:195
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:215
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:472
  11: rust_begin_unwind
             at src/libstd/panicking.rs:376
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:84
  13: core::panicking::panic
             at src/libcore/panicking.rs:51
  14: alloc::vec::Vec<T>::drain
             at ./<::core::macros::panic macros>:2
  15: alloc::vec::Vec<T>::splice
             at /rustc/a9c1c04e986dbf610be8cbe6a8107f90b4db61ce/src/liballoc/vec.rs:2180
  16: grex::grapheme::GraphemeCluster::replace_graphemes_with_repetitions
             at src/grapheme.rs:204
  17: grex::grapheme::GraphemeCluster::convert_repetitions
             at src/grapheme.rs:53
  18: grex::regexp::RegExp::grapheme_clusters
             at src/regexp.rs:123
  19: grex::regexp::RegExp::from
             at src/regexp.rs:93
  20: grex::regexp::RegExpBuilder::build
             at src/regexp.rs:69
  21: grex::handle_input
             at src/main.rs:109
  22: grex::main
             at src/main.rs:77
  23: std::rt::lang_start::{{closure}}
             at /rustc/a9c1c04e986dbf610be8cbe6a8107f90b4db61ce/src/libstd/rt.rs:67
  24: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  25: std::panicking::try::do_call
             at src/libstd/panicking.rs:296
  26: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:79
  27: std::panicking::try
             at src/libstd/panicking.rs:272
  28: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  29: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  30: std::rt::lang_start
             at /rustc/a9c1c04e986dbf610be8cbe6a8107f90b4db61ce/src/libstd/rt.rs:67
  31: main
  32: __libc_start_main
             at ../csu/libc-start.c:308
  33: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

It looks like the behavior is caused by unstable output of GraphemeCluster::sort_repetitions, but the input seems wrong as well ("AA" * 4 != "AAAAAA"[0..5]):

[src/grapheme.rs:154] &sorted_repetitions = [
    Some((["A", "A", "A"], 0..6, 2)),
    Some((["A", "A"], 0..5, 4)),
    Some((["A"], 0..6, 6)),
]
@pemistahl pemistahl added the bug Something isn't working label Jan 12, 2020
@pemistahl
Copy link
Owner

Thanks for your bug report @Mrmaxmeier. It is just in time because I'm currently finishing version 0.3.2 which fixes these problems. Please try the new version. Closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants