From d8d188301d7134c282d336e06dba23d1614ad208 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 30 Oct 2015 18:01:48 +0100 Subject: [PATCH] Fix division-by-zero crash Not clear why step_->jobsets was empty... --- src/hydra-queue-runner/builder.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hydra-queue-runner/builder.cc b/src/hydra-queue-runner/builder.cc index ae267a7d..929532ff 100644 --- a/src/hydra-queue-runner/builder.cc +++ b/src/hydra-queue-runner/builder.cc @@ -136,10 +136,12 @@ bool State::doBuildStep(std::shared_ptr store, Step::ptr step, among the jobsets that depend on it. */ { auto step_(step->state.lock()); - // FIXME: loss of precision. - time_t charge = (result.stopTime - result.startTime) / step_->jobsets.size(); - for (auto & jobset : step_->jobsets) - jobset->addStep(result.startTime, charge); + if (!step_->jobsets.empty()) { + // FIXME: loss of precision. + time_t charge = (result.stopTime - result.startTime) / step_->jobsets.size(); + for (auto & jobset : step_->jobsets) + jobset->addStep(result.startTime, charge); + } } /* Asynchronously compress the log. */