rust-lang / regex

An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.

Home Page:https://docs.rs/regex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attempting to parse {2} causes panic

frewsxcv opened this issue · comments

use regex::Regex;

extern crate regex;


fn main() {
    let _ = Regex::new("{2}");
}
/t/test (master|…) $ cargo run
     Running `target/debug/test`
thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcore/option.rs:362
An unknown error occurred

To learn more, run the command again with --verbose.

Was found using https://github.com/kmcallister/afl.rs 👍

This bug is fixed in my parser rewrite. Hopefully I'll get it merged soon!

Was found using https://github.com/kmcallister/afl.rs

Nice! What's the difference between afl and quickcheck?

@BurntSushi I'm not too familiar with the inner workings of AFL and I hadn't heard about 'quickcheck' until now, so I'm unsure :-/

From my so-so understanding of the two, quickcheck is more basic and human-guided. You specify how to generate values and what properties you want to verify, and it goes along generating inputs and testing them against your function.

afl is more automated. You give it a program and a data file, and it keeps mutating the file and feeding it to the program to explore different code paths and outputs. e.g. http://lcamtuf.blogspot.ca/2014/11/pulling-jpegs-out-of-thin-air.html describes how afl managed to reverse-engineer the jpeg format to generate random images given only a starting file that contains the string "hello world" and observing how a jpeg library reacted to it.

@BurntSushi What's the status of your rewrite?

Most of the parser is done. I just need to finish up char classes. Then tweak the compiler and I should be home free. Probably a couple more days of work. (But I'm working on Rust blog posts and presentations this week!)