Skip to content

Commit

Permalink
fix(libsinsp): Add a CPU count check
Browse files Browse the repository at this point in the history
In a scap file I have here, minfo->num_cpus is 0 when
sinsp_filter_check_thread::extract_exectime is called. We handle this in
debug builds with an ASSERT, but need to check for this in release
builds as well. Bail out early if we either have no CPUs or if minfo is
NULL.

Signed-off-by: Gerald Combs <[email protected]>
  • Loading branch information
geraldcombs authored and poiana committed Dec 11, 2023
1 parent cc5cedd commit 2174690
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions userspace/libsinsp/sinsp_filtercheck_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ uint64_t sinsp_filter_check_thread::extract_exectime(sinsp_evt *evt)
const scap_machine_info* minfo = m_inspector->get_machine_info();
ASSERT(minfo->num_cpus != 0);

if (minfo == NULL || minfo->num_cpus == 0) {
return res;
}

for(uint32_t j = 0; j < minfo->num_cpus; j++)
{
m_last_proc_switch_times.push_back(0);
Expand Down

0 comments on commit 2174690

Please sign in to comment.