ukaea / hdc

MIT License
0 stars 1 forks source link

Segfault when creating many child nodes #2

Open maarten-ic opened 1 year ago

maarten-ic commented 1 year ago

Hi @jholloc,

With the current master branch I frequently get bad_alloc exceptions and/or SEGFAULTS when initializing many child nodes on an HDC node.

Example program:

#include <hdc.hpp>
#include <iostream>

int main() {
    HDC hdc;
    for (int i=0; i<1024; i++ ) {
        std::string child_name = "Child#" + std::to_string(i);
        try {
            hdc.get_or_create(child_name);
        } catch (std::exception &ex) {
            std::cerr << "Caught exception '" << ex.what() << "' at i = " << i << std::endl;
            return 1;
        }
    }
    return 0;
}

When I compile and run this program on the master branch, this results in the program SEGFAULTing.

The last release (v0.21.0) doesn't have the same problem. After doing a git bisect, the issue seems to be this commit: 5fb812b13cea39a7aa6ddc293013dd63157e2c75

This commit touches a lot of logic, so I cannot pinpoint a likely cause..