Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linux: fix a getmntent() race during load()
getmntent() isn't thread safe, it uses a static internal struct mntent. Two concurrent hwloc_topology_load() would break if they call getmntent() (for finding the cgroup directory) at the same time. Use getmntent_r() instead. However we have to specify a buffer for storing mntent strings. And getmntent_r() doesn't actually report an error if the buffer is too small, it silently truncates output strings, so we can't dynamically realloc that buffer. The getmntent() that we used before this commit was internally limited to 4kB. And Linux actually limits mount options to 3 pages (during mount, not when reading /proc/mounts). So use 4 pages to be above both. Thanks to Corentin Rossignon for reporting the issue (using gcc -fsanitize=thread) Fixes #194 Refs #142 (cherry picked from commit 2337361)
- Loading branch information