Project

General

Profile

Bug #4216

5.0.5 in socket mode crashes when using file-store due to uninitialized stats_ctx

Added by Matt Bing 7 months ago. Updated about 5 hours ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:
Needs backport to 5.0, Needs backport to 6.0

Description

When using 5.0.5 in socket mode with a config that enables file-store:

# suricata -c /suricata.yaml -v --unix-socket=/tmp/suricata.socket
11/12/2020 -- 18:19:56 - <Notice> - This is Suricata version 5.0.5 RELEASE running in SYSTEM mode
11/12/2020 -- 18:19:56 - <Info> - CPUs/cores online: 8
suricata: counters.c:1007: StatsRegisterGlobalCounter: Assertion `!(stats_ctx == ((void *)0))' failed.
Aborted (core dumped)

This diff properly initializes stats_ctx and seems to fix the issue:

diff --git a/src/suricata.c b/src/suricata.c
index 5b76b0559..dbcc123fe 100644
--- a/src/suricata.c
+++ b/src/suricata.c
@@ -2300,10 +2300,10 @@ static int InitSignalHandler(SCInstance *suri)
  * Will be run once per pcap in unix-socket mode */
 void PreRunInit(const int runmode)
 {
+    StatsInit();
     if (runmode == RUNMODE_UNIX_SOCKET)
         return;

-    StatsInit();
 #ifdef PROFILING
     SCProfilingRulesGlobalInit();
     SCProfilingKeywordsGlobalInit();

Related issues

Copied to Bug #4301: 5.0.5 in socket mode crashes when using file-store due to uninitialized stats_ctxClosedJeff LucovskyActions
Copied to Bug #4302: 6.0.x in socket mode crashes when using file-store due to uninitialized stats_ctxClosedJason IshActions
#1

Updated by Jason Ish 7 months ago

  • Status changed from New to Assigned
  • Assignee set to Jason Ish
  • Affected Versions 6.0.1 added
  • Label Needs backport to 5.0, Needs backport to 6.0 added

Confirmed. 6.0 affected as well. I have a fix, will do a pull request soon.

#2

Updated by Jason Ish 6 months ago

  • Status changed from Assigned to In Review
#3

Updated by Victor Julien 6 months ago

  • Target version set to 7.0rc1
#4

Updated by Jeff Lucovsky 5 months ago

  • Copied to Bug #4301: 5.0.5 in socket mode crashes when using file-store due to uninitialized stats_ctx added
#5

Updated by Jeff Lucovsky 5 months ago

  • Copied to Bug #4302: 6.0.x in socket mode crashes when using file-store due to uninitialized stats_ctx added
#6

Updated by Jason Ish about 5 hours ago

  • Status changed from In Review to Closed

Merged into master a while back: 0aed5e188b214d56107e66ea8e38dfb7d5a13758

Also available in: Atom PDF