google / re2

RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Valgrind uninitialized memory access & jump during construction

jeking3 opened this issue · comments

With valgrind 3.20, code:

    RE2::Options options;
    options.set_max_mem(1 * GiB);
    options.set_dot_nl(true);  // "any" char includes newlines
    options.set_never_capture(true);  // do not bother saving capture state

    std::string excludes(".*/exclude\\.dir(|/.*)");
    new RE2(excludes, options);

valgrind --error-exitcode=42 --leak-check=full

==11965== Conditional jump or move depends on uninitialised value(s)
==11965==    at 0x5538448: contains (sparse_set.h:227)
==11965==    by 0x5538448: InsertInternal (sparse_set.h:156)
==11965==    by 0x5538448: insert (sparse_set.h:133)
==11965==    by 0x5538448: AddToQueue (prog.cc:138)
==11965==    by 0x5538448: re2::Prog::Optimize() (prog.cc:241)
==11965==    by 0x550DA07: re2::Compiler::Finish(re2::Regexp*) (compile.cc:1172)
==11965==    by 0x550FD82: re2::Compiler::Compile(re2::Regexp*, bool, long) (compile.cc:1156)
==11965==    by 0x553F866: re2::RE2::Init(re2::StringPiece const&, re2::RE2::Options const&) (re2.cc:253)
==11965==    by 0x55405DB: re2::RE2::RE2(re2::StringPiece const&, re2::RE2::Options const&) (re2.cc:152)
...
==11965== Use of uninitialised value of size 8
==11965==    at 0x553844A: contains (sparse_set.h:227)
==11965==    by 0x553844A: InsertInternal (sparse_set.h:156)
==11965==    by 0x553844A: insert (sparse_set.h:133)
==11965==    by 0x553844A: AddToQueue (prog.cc:138)
==11965==    by 0x553844A: re2::Prog::Optimize() (prog.cc:241)
==11965==    by 0x550DA07: re2::Compiler::Finish(re2::Regexp*) (compile.cc:1172)
==11965==    by 0x550FD82: re2::Compiler::Compile(re2::Regexp*, bool, long) (compile.cc:1156)
==11965==    by 0x553F866: re2::RE2::Init(re2::StringPiece const&, re2::RE2::Options const&) (re2.cc:253)
==11965==    by 0x55405DB: re2::RE2::RE2(re2::StringPiece const&, re2::RE2::Options const&) (re2.cc:152)

Thanks, @BurntSushi. I was just about to point to #391 (comment). ;)