Closed masklinn closed 6 months ago
Thanks for the report! This crash occurs here: set_
will be null until Compile()
has been called. I think raising ValueError
would be reasonable.
Having meditated on it a little more, raising re2.error
would be preferable – and arguably trivial as per this documentation.
Thanks for the report! This crash occurs here:
set_
will be null untilCompile()
has been called.
Oh yeah that's obvious now that you point it out, I had not noticed the Set
is only instantiated during compilation so I assumed that bit was fine and went on to look in the prefilter, sorry about that.
FYI, I just cut release 2024-04-01
(and published wheels) containing the fixes for this issue and also for issue https://github.com/google/re2/issues/485. :)
FYI, I just cut release
2024-04-01
(and published wheels) containing the fixes for this issue and also for issue #485. :)
Awesome, thanks.
This is inside tox, using python installed with pyenv, but reproduces with both Python 3.8 and 3.11.
I would assume it's because while there is a guard to check that the filter is compiled in
FirstMatch
https://github.com/google/re2/blob/108914d28a79243d4300e7e651cd0a0d5883ca0f/re2/filtered_re2.cc#L96-L99 there is no such guard forAllMatches
: https://github.com/google/re2/blob/108914d28a79243d4300e7e651cd0a0d5883ca0f/re2/filtered_re2.cc#L108-L118I assume the
PrefilterTree
would be the issue but apparently it guards against this https://github.com/google/re2/blob/108914d28a79243d4300e7e651cd0a0d5883ca0f/re2/prefilter_tree.cc#L271-L276 so I'm not sure why it SIGSEGVs, but I have not debugged the C++ code just looked at it.Interestingly there is a guard in
Set::Match
: https://github.com/google/re2/blob/108914d28a79243d4300e7e651cd0a0d5883ca0f/re2/set.cc#L128-L133 butFilter::Match
does not check it: https://github.com/google/re2/blob/108914d28a79243d4300e7e651cd0a0d5883ca0f/python/_re2.cc#L226 so it does not protect theFilteredRE2
(assuming that's what crashes, for all I know it might be something else entirely).