mulch-environment / mulch

mulch environment for structural biology
0 stars 0 forks source link

Seg fault making Collection and adding MDPs #10

Closed helenginn closed 1 year ago

helenginn commented 1 year ago
#include <src/Collection.h>

int main(int argc, char **argv)
{
    mulch::Collection *c = mulch::Collection::createCollection();

    std::cout << "I am here 0" << std::endl;
    c->addModel(Atomic, "3dpw.pdb");
    std::cout << "I am here 1" << std::endl;
    c->addModel(Atomic, "3dpz.pdb");

    std::cout << "I am here 2" << std::endl;

    c->persist();
    int id = c->getPrimaryId();

    std::cout << "ID to save: " << id << std::endl;

    return 0;
}

When I run this program, it seems to crash:

I am here 0
Adding data to ModelDataPair

175672304
Segmentation fault: 11
helenginn commented 1 year ago

OK: this only happens when I compile with optimization flags (i.e. meson --buildtype=release build/current causing -O3 optimisation flags to be passed to the compiler), so I can keep going for now.

In my (painful) experience, this usually points to a function which ought to return something, but exits without returning. In debug mode everything works well, but during optimisation the lack of return value causes chaos and eventual segmentation fault. It may also have another cause I am not expecting!

helenginn commented 1 year ago

this no longer happens!