1

解析器中的代码(const char* body, bool* parseFailure, bool* malformed):

303     string action;
312 
313     re2::StringPiece end;
314     bool match = RE2::PartialMatch(body,*m_alertRegex,
315                             &action,
326                             &end);

valgrind 的输出:

>     ==3826== 919 errors in context 11 of 11:
>     ==3826== Conditional jump or move depends on uninitialised value(s)
>     ==3826==    at 0x4E5826E: ??? (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E59466: ??? (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E5AF43: ??? (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E77976: re2::RE2::Match(re2::StringPiece const&, int, int, re2::RE2::Anchor, re2::StringPiece*, int) const (in
> /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E7A33E: re2::RE2::DoMatch(re2::StringPiece const&, re2::RE2::Anchor, int*, re2::RE2::Arg const* const*, int)
> const (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x436AB9: re2::VariadicFunction2<bool, re2::StringPiece const&, re2::RE2 const&, re2::RE2::Arg,
> &re2::RE2::PartialMatchN>::operator()(re2::StringPiece const&,
> re2::RE2 const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&) const (variadic_function.h:96)
>     ==3826==    by 0x4352AE: parser(char const*, bool*, bool*) (xxx.cpp:326)
>     ==3826==    by 0x4172FC: newThread(void*) (xxx.cpp:54)
>     ==3826==    by 0x5B4C181: start_thread (pthread_create.c:312)
>     ==3826==    by 0x637647C: clone (clone.S:111)
>     ==3826==  Uninitialised value was created by a heap allocation
>     ==3826==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>     ==3826==    by 0x4E5B67F: ??? (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E5ADCF: ??? (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E5AEFF: ??? (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E77976: re2::RE2::Match(re2::StringPiece const&, int, int, re2::RE2::Anchor, re2::StringPiece*, int) const (in
> /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x4E7A33E: re2::RE2::DoMatch(re2::StringPiece const&, re2::RE2::Anchor, int*, re2::RE2::Arg const* const*, int)
> const (in /opt/pkgs/libre2-e/lib/libre2.so.1.0.0)
>     ==3826==    by 0x436AB9: re2::VariadicFunction2<bool, re2::StringPiece const&, re2::RE2 const&, re2::RE2::Arg,
> &re2::RE2::PartialMatchN>::operator()(re2::StringPiece const&,
> re2::RE2 const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&, re2::RE2::Arg const&, re2::RE2::Arg const&,
> re2::RE2::Arg const&) const (variadic_function.h:96)
>     ==3826==    by 0x4352AE: parser(char const*, bool*, bool*) (xxx.cpp:326)
>     ==3826==    by 0x4172FC: newThread(void*) (xxx.cpp:54)
>     ==3826==    by 0x5B4C181: start_thread (pthread_create.c:312)
>     ==3826==    by 0x637647C: clone (clone.S:111)

已经仔细检查了这里的示例(https://gist.github.com/chezou/1395527)和这里的 StringPiece 的源代码https://github.com/google/re2/blob/master/re2/stringpiece.h但仍然不知道什么是未初始化的。有任何想法吗?谢谢

4

0 回答 0