Skip to content

fix(userspace/libsinsp): avoid bogus error in process_recvmsg_ancilla… #2381

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

Merged
merged 1 commit into from
May 1, 2025

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Apr 30, 2025

What type of PR is this?

/kind cleanup

Any specific area of the project related to this PR?

/area libsinsp

Does this PR require a change in the driver versions?

What this PR does / why we need it:

Since error is not always set, initialize it to empty.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

…ry_data_fds().

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@FedeDP
Copy link
Contributor Author

FedeDP commented Apr 30, 2025

/cc @leogr @ldegio

@poiana poiana requested a review from ldegio April 30, 2025 06:42
@FedeDP
Copy link
Contributor Author

FedeDP commented Apr 30, 2025

/milestone 0.21.0

@poiana poiana added this to the 0.21.0 milestone Apr 30, 2025
Copy link

Perf diff from master - unit tests

     6.70%     -1.31%  [.] sinsp_parser::reset
     5.97%     +0.94%  [.] sinsp::next
     5.16%     +0.52%  [.] sinsp_evt::get_type
     1.23%     -0.44%  [.] sinsp::fetch_next_event
     1.31%     -0.41%  [.] scap_event_decode_params
     4.08%     +0.37%  [.] sinsp_thread_manager::find_thread
     1.13%     +0.36%  [.] user_group_updater::~user_group_updater
     0.93%     -0.32%  [.] sinsp_evt::get_ts
     2.53%     -0.27%  [.] gzfile_read
     0.95%     +0.25%  [.] libsinsp::sinsp_suppress::process_event

Heap diff from master - unit tests

peak heap memory consumption: -160B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

peak heap memory consumption: -32B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Benchmarks diff from master

Comparing gbench_data.json to /root/actions-runner/_work/libs/libs/build/gbench_data.json
Benchmark                                                         Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------
BM_sinsp_split_mean                                            +0.0006         +0.0006           150           150           150           150
BM_sinsp_split_median                                          +0.0053         +0.0052           149           150           149           150
BM_sinsp_split_stddev                                          -0.3119         -0.3120             2             1             2             1
BM_sinsp_split_cv                                              -0.3123         -0.3124             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0728         +0.0728            59            64            59            64
BM_sinsp_concatenate_paths_relative_path_median                +0.0716         +0.0716            59            63            59            63
BM_sinsp_concatenate_paths_relative_path_stddev                -0.3225         -0.3222             1             1             1             1
BM_sinsp_concatenate_paths_relative_path_cv                    -0.3684         -0.3682             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0314         +0.0314            24            25            24            25
BM_sinsp_concatenate_paths_empty_path_median                   +0.0357         +0.0357            24            24            24            24
BM_sinsp_concatenate_paths_empty_path_stddev                   -0.3842         -0.3842             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       -0.4029         -0.4029             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0914         +0.0915            63            68            63            68
BM_sinsp_concatenate_paths_absolute_path_median                +0.1059         +0.1059            62            68            62            68
BM_sinsp_concatenate_paths_absolute_path_stddev                -0.7057         -0.7056             2             1             2             1
BM_sinsp_concatenate_paths_absolute_path_cv                    -0.7304         -0.7303             0             0             0             0

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 77.15%. Comparing base (beea29f) to head (84d0394).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/parsers.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2381   +/-   ##
=======================================
  Coverage   77.15%   77.15%           
=======================================
  Files         231      231           
  Lines       30347    30347           
  Branches     4656     4657    +1     
=======================================
  Hits        23415    23415           
  Misses       6932     6932           
Flag Coverage Δ
libsinsp 77.15% <0.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Copy link

X64 kernel testing matrix

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-4.19 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2-5.10 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2023-6.1 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.0 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.7 🟢 🟢 🟢 🟢 🟢 🟢
centos-3.10 🟢 🟢 🟢 🟡 🟡 🟡
centos-4.18 🟢 🟢 🟢 🟢 🟢 🟢
centos-5.14 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.17 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.8 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-3.10 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-4.14 🟢 🟢 🟢 🟢 🟢 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-5.4 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-4.15 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-5.8 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-6.5 🟢 🟢 🟢 🟢 🟢 🟢

ARM64 kernel testing matrix

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-4.14 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
ubuntu-6.5 🟢 🟢 🟢 🟢 🟢 🟢

Copy link
Contributor

@Molter73 Molter73 left a comment

Choose a reason for hiding this comment

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

/lgtm

@@ -3673,7 +3673,7 @@ inline void sinsp_parser::process_recvmsg_ancillary_data_fds(scap_platform *scap
int const *fds,
size_t const fds_len,
scap_threadinfo *scap_tinfo) {
char error[SCAP_LASTERR_SIZE];
char error[SCAP_LASTERR_SIZE] = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need the extra assignment here, though the compiler probably gets rid of it anyways

Suggested change
char error[SCAP_LASTERR_SIZE] = {};
char error[SCAP_LASTERR_SIZE]{};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That feels black magic syntax to me :O

Copy link
Contributor

Choose a reason for hiding this comment

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

It's explicitly calling the default constructor of the char[SCAP_LASTERR_SIZE] type, initializing its contents to zero. The behavior when leaving that out is the same as it would be on C, just leave any garbage in the stack laying around.

There's a better explanation here

Copy link
Contributor

@Molter73 Molter73 Apr 30, 2025

Choose a reason for hiding this comment

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

Again, the compiler probably catches that you are immediately copying new value into the array with the assignment and might just call the constructor for you and skip the copy, so either syntax will probably have the same result.

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

@github-project-automation github-project-automation bot moved this from Todo to In progress in Falco Roadmap May 1, 2025
@poiana
Copy link
Contributor

poiana commented May 1, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, Molter73

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Andreagit97,FedeDP,Molter73]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit 607ee60 into master May 1, 2025
47 of 48 checks passed
@poiana poiana deleted the fix/avoid_bogus_error branch May 1, 2025 13:17
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants