From bedc446c6be1af80ba365139cd74986dcc5f21fc Mon Sep 17 00:00:00 2001 From: Kamil Slowikowski Date: Fri, 23 Jan 2026 10:03:40 -0500 Subject: [PATCH] Fix uninitialized isRooted member in Builder class The Builder template class constructor was not initializing the isRooted member variable, leading to undefined behavior. On some platforms (particularly Linux with GCC), the uninitialized memory could contain non-zero garbage values. When isRooted was later used in calculations like: degree_of_root = isRooted ? 2 : 3 this caused incorrect tree construction behavior. For certain template instantiations (notably BIONJMatrix), this resulted in segmentation faults due to array bounds violations during tree construction. The bug was platform and algorithm dependent because: - Different compilers/platforms have different memory initialization - Different template instantiations have different memory layouts - NJ/RapidNJ happened to get zero values, while BIONJ got garbage This fix initializes isRooted to false in the constructor's initializer list, matching the other boolean members. --- starttree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starttree.h b/starttree.h index 74a6573..fc1c7b3 100644 --- a/starttree.h +++ b/starttree.h @@ -388,7 +388,7 @@ namespace StartTree Builder(const char* nameToUse, const char *descriptionToGive) : name(nameToUse), description(descriptionToGive), silent(false) , isOutputToBeAppended(false), isOutputToBeZipped(false) - , precision(6), subtreeOnly(false) { + , precision(6), isRooted(false), subtreeOnly(false) { } /**