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

Regex::is_match panics after successful creation with regex 0.2.4 #437

Closed
daboross opened this issue Dec 31, 2017 · 3 comments
Closed

Regex::is_match panics after successful creation with regex 0.2.4 #437

daboross opened this issue Dec 31, 2017 · 3 comments

Comments

@daboross
Copy link

Ran into this while building a dependency which uses bindgen. Seems the issue is with the regex at https://github.com/rust-lang-nursery/rust-bindgen/blob/04591f01d96a5c05e690dcf49d19d8e003eac7bf/src/clang.rs#L1060.

Reproduction:

extern crate regex;
fn main() {
    let thing = regex::Regex::new(r"typename type\-parameter\-\d+\-\d+::.+").unwrap();

    thing.is_match("test");
}

Error:

$ RUST_BACKTRACE=1 ./target/debug/reproduction-test 
thread 'main' panicked at 'assertion failed: haystack.len() >= self.pattern.len()', /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/literals.rs:602:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:397
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:538
   6: regex::literals::BoyerMooreSearch::find
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/literals.rs:602
   7: regex::dfa::Fsm::prefix_at
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/literals.rs:98
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/dfa.rs:1521
   8: regex::re_unicode::Regex::shortest_match_at
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/dfa.rs:708
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/dfa.rs:488
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/exec.rs:693
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/exec.rs:391
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/exec.rs:341
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/re_unicode.rs:633
   9: regex::re_unicode::Regex::is_match_at
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/re_unicode.rs:644
  10: regex::re_unicode::Regex::is_match
             at /home/daboross/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.2.4/src/re_unicode.rs:198
  11: reproduction_test::main
             at src/main.rs:5
  12: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  13: std::panicking::try::do_call
             at /checkout/src/libstd/rt.rs:59
             at /checkout/src/libstd/panicking.rs:480
  14: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:101
  15: std::rt::lang_start_internal
             at /checkout/src/libstd/panicking.rs:459
             at /checkout/src/libstd/panic.rs:365
             at /checkout/src/libstd/rt.rs:58
  16: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  17: main
  18: __libc_start_main
  19: _start

Occurs with regex 0.2.4 on x86_64 linux, works fine with regex 0.2.3.

Thanks!

BurntSushi added a commit that referenced this issue Dec 31, 2017
The TBM implementation tripped an assertion in debug mode if its
haystack was smaller than its query. This is incorrect. The correct
behavior is for TBM to report that no match can be found.

Fixes #437
@BurntSushi
Copy link
Member

BurntSushi commented Dec 31, 2017

Gah. Sorry. This was an oversight on my part. Fix incoming in #438. I'll get a new release out once that's merged.

BurntSushi added a commit that referenced this issue Dec 31, 2017
The TBM implementation tripped an assertion in debug mode if its
haystack was smaller than its query. This is incorrect. The correct
behavior is for TBM to report that no match can be found.

Fixes #437
@BurntSushi
Copy link
Member

BurntSushi commented Dec 31, 2017

regex 0.2.5 is on crates.io with a fix to this. Thanks so much for reporting this!

@daboross
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants