Skip to content

detect: fail thread init on keyword ctx error (v3) - #15630

Closed
ssam18 wants to merge 1 commit into
OISF:mainfrom
ssam18:filemagic-threadinit-fail-8237-v3
Closed

detect: fail thread init on keyword ctx error (v3)#15630
ssam18 wants to merge 1 commit into
OISF:mainfrom
ssam18:filemagic-threadinit-fail-8237-v3

Conversation

@ssam18

@ssam18 ssam18 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Contribution style:

Our Contribution agreements:

Changes (if applicable):

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:

  • ThreadCtxDoInit ignored the return of DetectEngineThreadCtxInitKeywords, so a failing per-thread keyword init (for example DetectFilemagicThreadInit) 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.
  • Adds a unit test (DetectEngineThreadCtxInitKeywordFailTest) that registers a keyword whose thread init fails and verifies DetectEngineThreadCtxInit reports the failure. It fails without the fix and passes with it (verified locally on this rebase).

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
@victorjulien victorjulien added this to the 9.0 milestone Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.88%. Comparing base (8a4eea4) to head (ff24139).

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     
Flag Coverage Δ
fuzzcorpus 61.36% <50.00%> (-0.01%) ⬇️
livemode 18.40% <50.00%> (-0.01%) ⬇️
netns 22.79% <50.00%> (+0.01%) ⬆️
pcap 45.14% <50.00%> (-0.08%) ⬇️
suricata-verify 66.63% <50.00%> (-0.04%) ⬇️
unittests 58.53% <95.83%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@victorjulien

Copy link
Copy Markdown
Member

Merged in #15636, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants