Skip to content

Commit 683604e

Browse files
gdankelfacebook-github-bot
authored andcommitted
Fix event profiler segfault (#322)
Summary: Pull Request resolved: #322 The change to lazy initialization of the ConfigLoader exposed an issue in the EventProfiler where a nullptr on demand configuration is dereferenced. On-demand configuration should only be accessed if the profiler is actually actively handling an on-demand request. Reviewed By: leitian Differential Revision: D29378839 fbshipit-source-id: dbccdc78268e0d87002b369b463fd42082b2be37
1 parent a941443 commit 683604e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

libkineto/src/EventProfiler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ void EventProfiler::dispatchSamples(
590590
}
591591

592592
void EventProfiler::configure(Config& config, Config* onDemandConfig) {
593-
LOG(INFO) << "configure";
594593
if (!sets_.empty()) {
595594
sets_[curEnabledSet_].setEnabled(false);
596595
clearSamples();

libkineto/src/EventProfilerController.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ void EventProfilerController::profilerLoop() {
351351
now = system_clock::now();
352352
next_sample_time = now + profiler_->samplePeriod();
353353
next_report_time = now + profiler_->reportPeriod();
354-
next_on_demand_report_time = now + profiler_->onDemandReportPeriod();
354+
if (profiler_->isOnDemandActive()) {
355+
next_on_demand_report_time = now + profiler_->onDemandReportPeriod();
356+
}
355357
next_multiplex_time = now + profiler_->multiplexPeriod();
356358
// Collect an initial sample and throw it away
357359
// The next sample is the first valid one
@@ -386,7 +388,7 @@ void EventProfilerController::profilerLoop() {
386388
profiler_->reportSamples();
387389
next_report_time += profiler_->reportPeriod();
388390
}
389-
if (on_demand_report_count && now > next_on_demand_report_time) {
391+
if (profiler_->isOnDemandActive() && now > next_on_demand_report_time) {
390392
VLOG(1) << "OnDemand Report #" << on_demand_report_count++;
391393
profiler_->reportOnDemandSamples();
392394
next_on_demand_report_time += profiler_->onDemandReportPeriod();

0 commit comments

Comments
 (0)