From 1d8126e6babbe0debedb21722c681b305415a605 Mon Sep 17 00:00:00 2001 From: monsanto-pinheiro Date: Sun, 26 Feb 2023 19:11:24 +0000 Subject: [PATCH] segmentation fault (core dumped) If you have all regions smaller than 78 (1260 >> kPSS), with coverage grather or equal ot 4, you don't have any valid "pile". When you try to calculate the median, a segmentation fault is raised. This solution avoids this, but I think it is better to inform the user about the lack of overlap because none contigs will be generated. --- RavenLib/src/construct.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/RavenLib/src/construct.cc b/RavenLib/src/construct.cc index 38b016c..f021d54 100644 --- a/RavenLib/src/construct.cc +++ b/RavenLib/src/construct.cc @@ -262,9 +262,13 @@ void ResolveChimericSequences( medians.emplace_back(it->median()); } } - std::nth_element(medians.begin(), medians.begin() + medians.size() / 2, + + std::uint16_t median = 0; + if (medians.size() > 0){ + std::nth_element(medians.begin(), medians.begin() + medians.size() / 2, medians.end()); - std::uint16_t median = medians[medians.size() / 2]; + median = medians[medians.size() / 2]; + } std::vector> thread_futures; for (const auto& it : piles) {