TravisWheelerLab / NINJA

Nearly Infinite Neighbor Joining Application
MIT License
5 stars 7 forks source link

Stack overflow #5

Closed michelwandermaas closed 8 years ago

michelwandermaas commented 8 years ago

Infinite loop between functions: CandidateHeap::clear() and TreeBuilderExtMem::~TreeBuilderExtMem(); causing a stack overflow.

The problem can be seen in: CandidateHeap::clear(): line 168 if (this->tb!=NULL){ delete this->tb; tb = NULL; }

TreeBuilderExtMem::~TreeBuilderExtMem(): line 93 if (candHeapList!=NULL){ for (int i=0;i<(signed)this->candHeapList->size();i++) if (this->candHeapList->at(i)!=NULL) this->candHeapList->at(i)->clear(); this->candHeapList->clear(); }

The bug is caused because both classes have objects of the other class that need to be deleted whenever one of them is deleted.

michelwandermaas commented 8 years ago

Fixed. CandidateHeap should not delete it`s this->tb because it is unnecessary and it would lead to infinite recursion.