From 325b700c620cd873a5e2c65c9cbe6bd36e6f1e8d Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Wed, 15 Apr 2020 14:19:49 +0200 Subject: [PATCH] Explicitly set initialization order for SparseMatrix to avoid nasty segfaults --- src/storm/storage/SparseMatrix.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/storm/storage/SparseMatrix.cpp b/src/storm/storage/SparseMatrix.cpp index 59d158d96..26e1c0dc7 100644 --- a/src/storm/storage/SparseMatrix.cpp +++ b/src/storm/storage/SparseMatrix.cpp @@ -406,7 +406,12 @@ namespace storm { } template - SparseMatrix::SparseMatrix(index_type columnCount, std::vector&& rowIndications, std::vector>&& columnsAndValues, boost::optional>&& rowGroupIndices) : rowCount(rowIndications.size() - 1), columnCount(columnCount), entryCount(columnsAndValues.size()), nonzeroEntryCount(0), columnsAndValues(std::move(columnsAndValues)), rowIndications(std::move(rowIndications)), trivialRowGrouping(!rowGroupIndices), rowGroupIndices(std::move(rowGroupIndices)) { + SparseMatrix::SparseMatrix(index_type columnCount, std::vector&& rowIndications, std::vector>&& columnsAndValues, boost::optional>&& rowGroupIndices) : columnCount(columnCount), nonzeroEntryCount(0), columnsAndValues(std::move(columnsAndValues)), rowIndications(std::move(rowIndications)), rowGroupIndices(std::move(rowGroupIndices)) { + // Initialize some variables here which depend on other variables + // This way we are more robust against different initialization orders + this->rowCount = this->rowIndications.size() - 1; + this->entryCount = this->columnsAndValues.size(); + this->trivialRowGrouping = !this->rowGroupIndices; this->updateNonzeroEntryCount(); }