detect: fail thread init on keyword ctx error (v3) - #15630
Closed
ssam18 wants to merge 1 commit into
Closed
Conversation
DetectEngineThreadCtxInitKeywords returns TM_ECODE_FAILED when a per-thread keyword init fails (for example DetectFilemagicThreadInit), but ThreadCtxDoInit discarded that result and still returned OK. The detect thread then ran with a partially initialized keyword context array, producing indeterminate results. Propagate the failure so the callers abort thread init and clean up. Add a unit test that registers a keyword whose thread init fails and verifies that DetectEngineThreadCtxInit reports the failure. Ticket: OISF#8237
5 tasks
victorjulien
approved these changes
Jun 12, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #15630 +/- ##
=======================================
Coverage 82.87% 82.88%
=======================================
Files 1006 1006
Lines 273527 273550 +23
=======================================
+ Hits 226698 226720 +22
- Misses 46829 46830 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Merged
Member
|
Merged in #15636, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution style:
https://docs.suricata.io/en/latest/devguide/contributing/contribution-process.html
Our Contribution agreements:
https://suricata.io/about/contribution-agreement/ (note: this is only required once)
Changes (if applicable):
(including schema descriptions)
https://redmine.openinfosecfoundation.org/projects/suricata/issues
Link to ticket: https://redmine.openinfosecfoundation.org/issues/8237
Replaces #15589, as requested by @victorjulien: rebased on current main and the cbindgen build-fix commit is dropped, since that issue has been fixed differently on main. This PR now contains only the thread init fix.
Describe changes:
ThreadCtxDoInitignored the return ofDetectEngineThreadCtxInitKeywords, so a failing per-thread keyword init (for exampleDetectFilemagicThreadInit) left a partially initialized keyword context array and the detect thread ran with indeterminate results. The failure is now propagated so the callers abort thread init and clean up.DetectEngineThreadCtxInitKeywordFailTest) that registers a keyword whose thread init fails and verifiesDetectEngineThreadCtxInitreports the failure. It fails without the fix and passes with it (verified locally on this rebase).