ukaea/hdc

Segfault when creating many child nodes

Opened this issue · 0 comments

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: 5fb812b

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