Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] get_topology function does not destroy hwloc_topology_t instance, leading to Too many open files error and segfault #650

Closed
GuilloteauQ opened this issue Jan 22, 2024 · 0 comments · Fixed by #651

Comments

@GuilloteauQ
Copy link
Contributor

The get_topology function is responsible to set up several vectors with the correct size based on the underlying topology.

void get_topology(std::vector<int> &physicalIds, std::vector<int> &uniqueThreads, std::vector<int> &responsibleThreads) {
hwloc_topology_t topology;
hwloc_topology_init(&topology);
hwloc_topology_load(topology);
physicalIds.resize(hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_PACKAGE));
uniqueThreads.resize(hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_CORE));
responsibleThreads.resize(hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_PU));
}

However, the topology object keeps a file open while alive, and this object is not destroyed.
This issue leads to a sneaky Too many open fileserror, and makes hwloc return nonsense values which cause segfault later on in the program.

get_topology should call at the end of the scope by calling

hwloc_topology_destroy(topology);

doc: https://www.open-mpi.org/projects/hwloc/doc/v2.10.0/a00139.php#ga9f34a640b6fd28d23699d4d084667b15

I will prepare a pull request

GuilloteauQ pushed a commit to GuilloteauQ/daphne that referenced this issue Jan 22, 2024
CPestka pushed a commit to CPestka/daphne that referenced this issue Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant