Skip to content

fix(libsinsp): use gmtime_r instead of gmtime for thread safety#2953

Draft
irozzo-1A wants to merge 1 commit into
falcosecurity:masterfrom
irozzo-1A:sinsp-utils-ts
Draft

fix(libsinsp): use gmtime_r instead of gmtime for thread safety#2953
irozzo-1A wants to merge 1 commit into
falcosecurity:masterfrom
irozzo-1A:sinsp-utils-ts

Conversation

@irozzo-1A

Copy link
Copy Markdown
Contributor

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind test

/kind feature

/kind sync

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area API-version

/area build

/area CI

/area driver-kmod

/area driver-modern-bpf

/area libscap-engine-kmod

/area libscap-engine-modern-bpf

/area libscap-engine-nodriver

/area libscap-engine-noop

/area libscap-engine-source-plugin

/area libscap-engine-savefile

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

/version driver-API-version-major

/version driver-API-version-minor

/version driver-API-version-patch

/version driver-SCHEMA-version-major

/version driver-SCHEMA-version-minor

/version driver-SCHEMA-version-patch

What this PR does / why we need it:

Preparatory work for falcosecurity/falco#3749

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

chore(libsinsp): use gmtime_r instead of gmtime in sinsp utils for thread-safety

Signed-off-by: irozzo-1A <iacopo@sysdig.com>
@poiana

poiana commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irozzo-1A

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

The pull request process is described here

Details Needs approval from an approver in each of these files:

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

@github-actions

Copy link
Copy Markdown

Perf diff from master - unit tests

    14.42%     -3.94%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_add_ref_lock_nothrow()
    11.41%     +2.58%  [.] std::__shared_count<(__gnu_cxx::_Lock_policy)2>::_M_get_use_count() const
     7.73%     +2.34%  [.] sinsp_threadinfo::update_main_fdtable()
     9.25%     -1.60%  [.] sinsp_threadinfo::get_fd_table()
    15.28%     +1.07%  [.] std::__shared_ptr<sinsp_threadinfo, (__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__weak_ptr<sinsp_threadinfo, (__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t)
     4.99%     -0.54%  [.] thread_group_info::get_first_thread() const
     6.60%     +0.21%  [.] std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count(std::__weak_count<(__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t)
    11.20%     -0.15%  [.] sinsp_threadinfo::get_main_thread()
     9.65%     +0.11%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()
     0.55%     +0.08%  [.] sinsp_thread_manager::clear()

Heap diff from master - unit tests

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

Heap diff from master - scap file

peak heap memory consumption: 0B
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.0005         +0.0006           237           237           237           237
BM_sinsp_split_median                                          -0.0044         -0.0044           237           236           237           236
BM_sinsp_split_stddev                                          +2.6665         +2.6090             1             3             1             3
BM_sinsp_split_cv                                              +2.6647         +2.6069             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  -0.0130         -0.0130            71            70            71            70
BM_sinsp_concatenate_paths_relative_path_median                -0.0249         -0.0247            72            70            72            70
BM_sinsp_concatenate_paths_relative_path_stddev                -0.9729         -0.9732             2             0             2             0
BM_sinsp_concatenate_paths_relative_path_cv                    -0.9725         -0.9728             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0017         +0.0017            42            42            42            42
BM_sinsp_concatenate_paths_empty_path_median                   +0.0431         +0.0434            40            42            40            42
BM_sinsp_concatenate_paths_empty_path_stddev                   -0.8879         -0.8880             3             0             3             0
BM_sinsp_concatenate_paths_empty_path_cv                       -0.8881         -0.8882             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  -0.0099         -0.0099            69            68            69            68
BM_sinsp_concatenate_paths_absolute_path_median                -0.0008         -0.0010            68            68            68            68
BM_sinsp_concatenate_paths_absolute_path_stddev                -0.5538         -0.5557             1             1             1             1
BM_sinsp_concatenate_paths_absolute_path_cv                    -0.5493         -0.5513             0             0             0             0

@codecov

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.92%. Comparing base (6fdb0f3) to head (0af89fa).
⚠️ Report is 121 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/utils.cpp 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2953      +/-   ##
==========================================
- Coverage   74.92%   74.92%   -0.01%     
==========================================
  Files         297      297              
  Lines       31516    31517       +1     
  Branches     4982     4982              
==========================================
  Hits        23613    23613              
- Misses       7903     7904       +1     
Flag Coverage Δ
libsinsp 74.92% <0.00%> (-0.01%) ⬇️

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.

@ekoops ekoops added this to the 0.25.0 milestone Apr 16, 2026
@leogr leogr modified the milestones: 0.25.0, 0.26.0 Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants