Skip to content

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

Closed
@daboross

Description

@daboross

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!

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