intel / hyperscan

High-performance regular expression matching library
https://www.hyperscan.io
Other
4.81k stars 718 forks source link

Why HS_FLAG_SINGLEMATCH can't combination with HS_FLAG_SOM_LEFTMOST #103

Open ipandtcp opened 6 years ago

ipandtcp commented 6 years ago

Hi I was wonder why HS_FLAG_SINGLEMATCH can't combination with HS_FLAG_SOM_LEFTMOST. Because i must set HS_FLAG_SINGLEMATCH flag and i must get "from" value when match_event_handler called. What should i do? I find "UE-1850" in hyperscan source code about this and i google it but no info about "UE-1850". And i had try simply delete the check code, and it seem work. Thanks, best regards.

fatchanghao commented 6 years ago

The reason we reject using HS_FLAG_SINGLEMATCH in combine with HS_FLAG_SOM_LEFTMOST is due to our internal design, when you remove this check code, it works in most cases, but may fail in some cases such as matches at EOD position. We will fix this issue in the future. Thanks, Harry

xjjy1083 commented 6 years ago

@fatchanghao Is this restriction only for the stream mode?

fatchanghao commented 6 years ago

Unfortunately no, the block mode also has same problem, actually in current version such expression may report match at EOD even it had already reported a match previously, which violates the SINGLE_MATCH behaviour.

xjjy1083 commented 6 years ago

@fatchanghao When i remove this check code, what was the worst will happend?

  1. program crash?
  2. match failed?
  3. violate the SINGLE_MATCH behaviour?

In most cases, will the matching times be reduced and the performance be improved?

fatchanghao commented 6 years ago

@xjjy1083 The worst is 3, no worry about crash or matching failure.

pelletier197 commented 5 months ago

I have encountered a need for that as well (I don't believe we're on the latest hyperscan however). I was wondering if this had been fixed in latest versions?