Skip to content

Gcc analyzer/v1 - #15559

Closed
victorjulien wants to merge 16 commits into
OISF:mainfrom
victorjulien:gcc-analyzer/v1
Closed

Gcc analyzer/v1#15559
victorjulien wants to merge 16 commits into
OISF:mainfrom
victorjulien:gcc-analyzer/v1

Conversation

@victorjulien

Copy link
Copy Markdown
Member

Gcc analyzer fixes and CI test.

Comment thread src/detect-engine.c
de_ctx->RateFilterCallback = fn;
de_ctx->rate_filter_callback_arg = arg;
DetectEngineDeReference(&de_ctx);
if (de_ctx) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will drop this after #15558 gets merged

@suricata-qa

Copy link
Copy Markdown

Information:

ERROR: QA failed on SURI_TLPW1_suri_time.

ERROR: QA failed on SURI_TLPW1_files_sha256.

field baseline test %
SURI_TLPW1_stats_chk
.uptime 78 74 94.87%
.file_store.fs_errors 0 251565 -

Pipeline = 31861

@victorjulien
victorjulien force-pushed the gcc-analyzer/v1 branch 2 times, most recently from 22f1fbe to a8d1800 Compare June 4, 2026 18:41
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.67939% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.84%. Comparing base (0eda09f) to head (f3fd348).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15559      +/-   ##
==========================================
- Coverage   82.86%   82.84%   -0.02%     
==========================================
  Files         999      999              
  Lines      272627   272667      +40     
==========================================
- Hits       225904   225889      -15     
- Misses      46723    46778      +55     
Flag Coverage Δ
fuzzcorpus 61.48% <63.00%> (-0.01%) ⬇️
livemode 18.40% <11.00%> (+<0.01%) ⬆️
netns 22.79% <15.53%> (-0.04%) ⬇️
pcap 45.19% <32.00%> (-0.02%) ⬇️
suricata-verify 66.56% <73.63%> (-0.01%) ⬇️
unittests 58.48% <44.06%> (-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.

@suricata-qa

Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPW1_stats_chk
.file_store.open_files 0 4294918119 -

Pipeline = 31864

2 similar comments
@suricata-qa

Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPW1_stats_chk
.file_store.open_files 0 4294918119 -

Pipeline = 31864

@suricata-qa

Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPW1_stats_chk
.file_store.open_files 0 4294918119 -

Pipeline = 31864

@suricata-qa

Copy link
Copy Markdown

Information: QA ran without warnings.

Pipeline = 31880

To assist code analyzers. Gcc -fanalyzer got confused about it.

Also test data pointer and length before calling fwrite and check the
result better.

Use a single atomic for the max open files check.
Code analyzer flagged FrameCopy as a possible source of UB due to
both pointers passed to memcpy being the same.

app-layer-frames.c: In function ‘FrameCopy’:
app-layer-frames.c:236:5: warning: overlapping buffers passed as arguments to ‘memcpy’ [-Wanalyzer-overlapping-buffers]
  236 |     memcpy(dst, src, sizeof(*dst));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ‘FramePrune’: events 1-8
    │
    │  750 | static void FramePrune(Frames *frames, const TcpStream *stream, const bool eof)
    │      |             ^~~~~~~~~~
    │      |             |
    │      |             (1) entry to ‘FramePrune’
    │......
    │  766 |     for (uint16_t i = 0; i < frames->cnt; i++) {
    │      |                          ~~~~~~~~~~~~~~~
    │      |                            |
    │      |                            (2) following ‘true’ branch... ─>─┐
    │      |                                                              │
    │      |                                                              │
    │      |┌─────────────────────────────────────────────────────────────┘
    │  767 |│        if (i < FRAMES_STATIC_CNT) {
    │      |│           ~
    │      |│           |
    │      |└──────────>(3) ...to here
    │      |            (4) following ‘true’ branch (when ‘i <= 2’)... ─>─┐
    │      |                                                              │
    │      |                                                              │
    │      |┌─────────────────────────────────────────────────────────────┘
    │  768 |│            Frame *frame = &frames->sframes[i];
    │      |│                            ~~~~~~~~~~~~~~~~~~
    │      |│                                           |
    │      |└──────────────────────────────────────────>(5) ...to here
    │  769 |             FrameDebug("prune(s)", frames, frame);
    │  770 |             if (eof || FrameIsDone(frame, acked)) {
    │      |                ~
    │      |                |
    │      |                (6) following ‘false’ branch... ─>─┐
    │      |                                                   │
    │......
    │      |                                                   │
    │      |┌──────────────────────────────────────────────────┘
    │  779 |│                const uint64_t fle = FrameLeftEdge(stream, frame);
    │      |│                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    │      |│                                     |
    │      |└────────────────────────────────────>(7) ...to here
    │      |                                      (8) calling ‘FrameLeftEdge’ from ‘FramePrune’
    │
    └──> ‘FrameLeftEdge’: event 9
           │
           │  257 | static inline uint64_t FrameLeftEdge(const TcpStream *stream, const Frame *frame)
           │      |                        ^~~~~~~~~~~~~
           │      |                        |
           │      |                        (9) entry to ‘FrameLeftEdge’
           │
         ‘FrameLeftEdge’: event 10
           │
           │suricata-common.h:323:27:
           │  323 |         #define BUG_ON(x) assert(!(x))
           │      |                           ^~~~~~
           │      |                           |
           │      |                           (10) following ‘false’ branch (when ‘frame_offset <= app_progress’)... ─>─┐
           │      |                                                                                                     │
util-validate.h:95:36: note: in expansion of macro ‘BUG_ON’
           │   95 | #define DEBUG_VALIDATE_BUG_ON(exp) BUG_ON((exp))
           │      |                                    ^~~~~~
app-layer-frames.c:266:5: note: in expansion of macro ‘DEBUG_VALIDATE_BUG_ON’
           │  266 |     DEBUG_VALIDATE_BUG_ON(frame_offset > app_progress);
           │      |     ^~~~~~~~~~~~~~~~~~~~~
           │
         ‘FrameLeftEdge’: event 11
           │
           │      |                                                                                                     │
           │      |┌────────────────────────────────────────────────────────────────────────────────────────────────────┘
           │  269 |│    if (frame->len < 0) {
           │      |│        ~~~~~^~~~~
           │      |│             |
           │      |└────────────>(11) ...to here
           │
    <──────┘
    │
  ‘FramePrune’: events 12-13
    │
    │  779 |                 const uint64_t fle = FrameLeftEdge(stream, frame);
    │      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    │      |                                      |
    │      |                                      (12) returning to ‘FramePrune’ from ‘FrameLeftEdge’
    │......
    │  783 |                 FrameCopy(nframe, frame);
    │      |                 ~~~~~~~~~~~~~~~~~~~~~~~~
    │      |                 |
    │      |                 (13) calling ‘FrameCopy’ from ‘FramePrune’
    │
    └──> ‘FrameCopy’: events 14-15
           │
           │  234 | static void FrameCopy(Frame *dst, Frame *src)
           │      |             ^~~~~~~~~
           │      |             |
           │      |             (14) entry to ‘FrameCopy’
           │  235 | {
           │  236 |     memcpy(dst, src, sizeof(*dst));
           │      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           │      |     |
           │      |     (15) ⚠️  overlapping buffers passed as arguments to ‘memcpy’
           │
In file included from suricata-common.h:129,
                 from app-layer-frames.c:25:
/usr/include/string.h:47:14: note: the behavior of ‘memcpy’ is undefined for overlapping buffers
   47 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
      |              ^~~~~~
Work around TAILQ false positive.
Work around TAILQ false positive.
Addresses a gcc -fanalyzer warning.
Add debug validation statement to assert prev pointer is not NULL.
Helps address a gcc -fanalyzer warning.
Reopen file descriptor for lz4 with the init function. This helps
code analyzers understand the handle it's leaked.

Improve flow of profiling dumps to avoid analyzer confusion around the
file descriptor.

Suppress TAILQ related warnings.
By teaching about TAILQ.
The double strchr confused gcc -fanalyzer.
Avoids gcc -fanalyzer warning about out of bounds write to the array.
Help it understand TAILQ.
Pointer can't be NULL, so don't check it.

Helps gcc analyzer as well.
Make sure to not run against lua rust crate build, as it's not clean.
@suricata-qa

Copy link
Copy Markdown

Information: QA ran without warnings.

Pipeline = 31881

@victorjulien victorjulien mentioned this pull request Jun 11, 2026
@victorjulien

Copy link
Copy Markdown
Member Author

replaced by #15607

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