Skip to content

Commit

Permalink
fix(process monitoring): dont abort lo2s on unexpected child process
Browse files Browse the repository at this point in the history
exit

If currently a process exits after ptrace catched it but before
sampling with perf_event_open has been set up, perf_event_open will
throw ESRCH ("no such process"), aborting lo2s.

Change the behaviour on an exception in ScopeMonitor so lo2s merely prints a warning instead of exiting, as no error in the ScopeMonitor should affect the measurement as a whole
  • Loading branch information
cvonelm committed Mar 14, 2024
1 parent 161b93c commit a5e5972
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/monitor/process_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,19 @@ void ProcessMonitor::insert_thread(Process process, Thread thread, std::string n
perf::counter::CounterProvider::instance().has_group_counters(ExecutionScope(thread)) ||
perf::counter::CounterProvider::instance().has_userspace_counters(ExecutionScope(thread)))
{
auto inserted =
threads_.emplace(std::piecewise_construct, std::forward_as_tuple(thread),
std::forward_as_tuple(ExecutionScope(thread), *this, spawn));
assert(inserted.second);
// actually start thread
inserted.first->second.start();
try
{
auto inserted =
threads_.emplace(std::piecewise_construct, std::forward_as_tuple(thread),
std::forward_as_tuple(ExecutionScope(thread), *this, spawn));
assert(inserted.second);
// actually start thread
inserted.first->second.start();
}
catch (const std::exception& e)
{
Log::warn() << "Could not start measurement for " << thread << ": " << e.what();
}
}

trace_.update_thread_name(thread, name);
Expand Down

0 comments on commit a5e5972

Please sign in to comment.