Skip to content

Commit

Permalink
gh-537: roc_pipeline benchmark: fix a task completer race
Browse files Browse the repository at this point in the history
In peakload benchmarks it is possible for the TaskThread object to be
removed along with the pipeline_task_completed() callback before all
tasks are completed. This results in a SIGABRT with "pure virtual method
called" message.

To fix this move pipeline_task_completed() to TestPipeline class that has
a longer lifespan.

Fixes: #537
  • Loading branch information
sm00th committed Dec 15, 2024
1 parent d90cf31 commit ee3f557
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/tests/roc_pipeline/bench_pipeline_loop_peak_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class DelayStats {
};

class TestPipeline : public PipelineLoop,
public IPipelineTaskCompleter,
private IPipelineTaskScheduler,
public ctl::ControlTaskExecutor<TestPipeline> {
public:
Expand Down Expand Up @@ -319,6 +320,11 @@ class TestPipeline : public PipelineLoop,
state.counters["sc"] = st.scheduler_cancellations;
}

virtual void pipeline_task_completed(PipelineTask& basic_task) {
TestPipeline::Task& task = (TestPipeline::Task&)basic_task;
delete &task;
}

using PipelineLoop::process_subframes_and_tasks;

private:
Expand Down Expand Up @@ -375,7 +381,7 @@ class TestPipeline : public PipelineLoop,
BackgroundProcessingTask control_task_;
};

class TaskThread : public core::Thread, private IPipelineTaskCompleter {
class TaskThread : public core::Thread {
public:
TaskThread(TestPipeline& pipeline)
: pipeline_(pipeline)
Expand All @@ -400,16 +406,11 @@ class TaskThread : public core::Thread, private IPipelineTaskCompleter {

task->start();

pipeline_.schedule(*task, *this);
pipeline_.schedule(*task, pipeline_);
}
}
}

virtual void pipeline_task_completed(PipelineTask& basic_task) {
TestPipeline::Task& task = (TestPipeline::Task&)basic_task;
delete &task;
}

TestPipeline& pipeline_;
core::Atomic<int> stop_;
};
Expand Down

0 comments on commit ee3f557

Please sign in to comment.