iqtree / piqtree2

a python library that exposes features from iqtree2 - efficient software for phylogenomic inference
GNU General Public License v2.0
6 stars 1 forks source link

Segmentation fault on some chains of calls with bad input #21

Open rmcar17 opened 5 days ago

rmcar17 commented 2 days ago

Here is a minimal example:

from piqtree2._iq_wrappers import iq_build_tree, iq_random_tree

iq_build_tree(["a", "b", "c", "d"], ["GGG", "GGC", "AAC", "AAA"], "JC", 1)
iq_build_tree(["a", "b", "c", "d"], ["GGG", "GGC", "AAC", "AAA"], "JC", 2)
iq_random_tree(2, "BALANCED", 3, 1)

The iq_ functions are the exposed functions on the IQ-TREE side. Lists are automatically transformed into vectors.

iq_random_tree here should throw a RuntimeError on the IQ-TREE side. It does when called by itself, or when either of the two lines above it are missing.

However, when build_tree or fit_tree is called at least two times above it, instead of the C++ code throwing an error it causes a segmentation fault. Curiously, the segmentation fault does not arise on good inputs (say I use three taxa instead of two taxa).