hyperscan icon indicating copy to clipboard operation
hyperscan copied to clipboard

Memory leak when both HS_FLAG_UTF8 + HS_FLAG_CASELESS are used

Open liquidaty opened this issue 2 years ago • 0 comments

Compiling simplegrep.c, but with HS_FLAG_UTF8 | HS_FLAG_CASELESS instead of HS_FLAG_DOTALL, results in a small (16-byte) leak reported by both valgrind and, on macOS, leaks.

Valgrind identifies it as originating from:

16 bytes in 1 blocks are definitely lost in loss record 14 of 343
==85261==    at 0x100E74545: malloc (in /usr/local/Cellar/valgrind/HEAD-6ff08b6/libexec/valgrind/vgpreload_memcheck-amd64-darwin.so)
==85261==    by 0x100EF23FD: __cxa_get_globals (in /usr/local/Cellar/gcc/11.2.0/lib/gcc/11/libstdc++.6.dylib)
==85261==    by 0x10093F277: ??? (in ..)
==85261==    by 0x100EF33C2: __cxa_throw (in /usr/local/Cellar/gcc/11.2.0/lib/gcc/11/libstdc++.6.dylib)
==85261==    by 0x1056639AF: ???
==85261==    by 0x105663A2F: ???
==85261==    by 0x108460BBF: ???
==85261==    by 0x10077BFF6: ue2::ConstructLiteralVisitor::pre(ue2::ComponentAlternation const&) (in ..)
==85261==    by 0x1056639DF: ???
==85261==    by 0x1004F578C: ue2::ComponentAlternation::accept(ue2::ConstComponentVisitor&) const (in ..)
==85261==    by 0x108467127: ???
==85261==    by 0x105663A2F: ???
...

In my own tests, the same issue occurs with hs_compile_multi() and the leak size is always 16 bytes regardless of the number of patterns or the size of the input

liquidaty avatar Sep 03 '22 20:09 liquidaty