Skip to content
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

fix(libsinsp): fix crash in string transformers when called on an empty string #1942

Merged

Conversation

LucaGuerra
Copy link
Contributor

@LucaGuerra LucaGuerra commented Jul 1, 2024

What type of PR is this?

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

/kind bug

Any specific area of the project related to this PR?

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

/area libsinsp

Does this PR require a change in the driver versions?

No

What this PR does / why we need it:

Fix a potential crash in string transformers when attempting to read an empty output buffer.
Also, lightly refactor tests and cover the empty string case.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(libsinsp): fix crash in string transformers when called on an empty string

@LucaGuerra
Copy link
Contributor Author

/milestone 0.18.0

@poiana poiana added this to the 0.18.0 milestone Jul 1, 2024
@poiana poiana added the size/L label Jul 1, 2024
Copy link

github-actions bot commented Jul 1, 2024

Perf diff from master - unit tests

     4.72%     -0.85%  [.] sinsp_parser::process_event
     5.50%     -0.80%  [.] next
     3.76%     +0.77%  [.] sinsp_evt::load_params
     1.55%     -0.75%  [.] 0x00000000000e7390
     1.29%     +0.62%  [.] std::_Hashtable<long, std::pair<long const, std::shared_ptr<sinsp_threadinfo> >, std::allocator<std::pair<long const, std::shared_ptr<sinsp_threadinfo> > >, std::__detail::_Select1st, std::equal_to<long>, std::hash<long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_find_before_node
     3.04%     -0.53%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release
     1.19%     +0.48%  [.] sinsp::fetch_next_event
     0.46%     +0.48%  [.] sinsp_threadinfo::~sinsp_threadinfo
     1.85%     -0.47%  [.] sinsp_evt::get_ts
     0.05%     +0.38%  [.] sinsp_container_info::~sinsp_container_info

Perf diff from master - scap file

     3.78%     +4.39%  [.] sinsp_filter_check::apply_transformers
    11.32%     -2.88%  [.] sinsp_filter_check::tostring
     6.22%     -1.53%  [.] sinsp_parser::process_event
     3.75%     +1.47%  [.] sinsp_filter_check::get_field_info
     5.62%     -1.41%  [.] std::_Hashtable<long, std::pair<long const, std::shared_ptr<sinsp_threadinfo> >, std::allocator<std::pair<long const, std::shared_ptr<sinsp_threadinfo> > >, std::__detail::_Select1st, std::equal_to<long>, std::hash<long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_find_before_node
     5.42%     -1.29%  [.] sinsp_evt::get_thread_info
     7.62%     -1.19%  [.] sinsp_thread_manager::find_thread
     3.78%     +0.99%  [.] sinsp_filter_check_thread::extract_single
     7.00%     -0.79%  [.] std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>
     3.78%     -0.61%  [.] gzfile_read

Heap diff from master - unit tests

total runtime: -0.20s.
calls to allocation functions: 652 (-3180/s)
temporary memory allocations: 288 (-1404/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

total runtime: 0.01s.
calls to allocation functions: 0 (0/s)
temporary memory allocations: -1 (-71/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

@poiana
Copy link
Contributor

poiana commented Jul 1, 2024

LGTM label has been added.

Git tree hash: ada1edbc4d215dbac8286ee3c00f82695cf41a9b

Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve
Great catch ™️ !

@poiana
Copy link
Contributor

poiana commented Jul 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, jasondellaluce, LucaGuerra

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 [FedeDP,LucaGuerra,jasondellaluce]

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 a1f8b3b into falcosecurity:master Jul 1, 2024
42 of 43 checks passed
@LucaGuerra LucaGuerra deleted the fix/empty-string-transformer branch July 1, 2024 13:31
@LucaGuerra LucaGuerra mentioned this pull request Jul 23, 2024
@FedeDP
Copy link
Contributor

FedeDP commented Jul 31, 2024

/milestone 0.17.3

@poiana poiana modified the milestones: 0.18.0, 0.17.3 Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants