I am getting a segfault from hs_compile_multi() when trying to compile a
pattern of length ~1.5 MB. Using the same test code, I can compile a
similarly structured, but much smaller (~1K) pattern without error.
I see in grey.h that there is a fixed limit on pattern size, but also that
an error should be thrown when my pattern exceeds the limit:
https://github.com/01org/hyperscan
/blob/master/src/compiler/compiler.cpp#L229
Unfortunately, it is the strlen() call on that line that is causing the
segfault:
Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: No such file or directory.
(gdb) bt
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x000000000040a9d6 in ue2::addExpression (ng=..., index=index@entry=0,
expression=0x7ffff7075028 <error: Cannot access memory at address
0x7ffff7075028>, flags=1, ext=0x0, id=0)
at /home/ubuntu/workspace/hyperscan/src/compiler/compiler.cpp:229
#2 0x0000000000408845 in ue2::hs_compile_multi_int
(expressions=expressions@entry=0x8fa260, flags=flags@entry=0x8fa280,
ids=ids@entry=0x8fa2a0, ext=ext@entry=0x0, elements=elements@entry=1,
mode=mode@entry=1, platform=platform@entry=0x0,
db=db@entry=0x7fffffffde60, comp_error=comp_error@entry=0x7fffffffde68,
g=...) at /home/ubuntu/workspace/hyperscan/src/hs.cpp:229
#3 0x0000000000408fec in hs_compile_multi (expressions=0x8fa260,
flags=0x8fa280, ids=0x8fa2a0, elements=1, mode=1, platform=0x0,
db=0x7fffffffde60, error=0x7fffffffde68) at /home/ubuntu/workspace/hyperscan
/src/hs.cpp:297
#4 0x0000000000406aae in main (argc=2, argv=0x7fffffffe1e8) at
hs_compile.c:35
A few questions:
1) How can I tell at runtime what the max allowed pattern size is?
2) Is the above segfault a bug or a misuse of the library?
Thanks,
m.