-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pcre: creates a match structure per match run #6425
Conversation
So that DetectPcrePayloadMatch is thread safe and does not rewrite a shared parse_regex.match structure
Codecov Report
@@ Coverage Diff @@
## master #6425 +/- ##
==========================================
- Coverage 76.92% 76.91% -0.01%
==========================================
Files 613 613
Lines 186677 186681 +4
==========================================
- Hits 143597 143589 -8
- Misses 43080 43092 +12
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -199,7 +200,8 @@ int DetectPcrePayloadMatch(DetectEngineThreadCtx *det_ctx, const Signature *s, | |||
} | |||
|
|||
/* run the actual pcre detection */ | |||
ret = DetectPcreExec(det_ctx, pe, (char *)ptr, len, start_offset, 0); | |||
pcre2_match_data *match = pcre2_match_data_create_from_pattern(pe->parse_regex.regex, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use thread specific data with DetectRegisterThreadCtxFuncs
, DetectThreadCtxGetKeywordThreadCtx
. See src/detect-lua.c
for an example implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Victor.
I gathered from your answer that
- this was indeed one bug
- the performance impact could be avoided
Replaced by #6427 |
Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/4720
Describe changes:
pcre2_match_data
for each call ofDetectPcrePayloadMatch
I am not sure this is the problem.
But if there are two threads which can call concurrently
DetectPcrePayloadMatch
with the sameDetectPcreData
(ie SigMatchData context), that is indeed a problemTODO