Skip to content

Commit

Permalink
Merge pull request #5690 from grondo/issue#5689
Browse files Browse the repository at this point in the history
librlist: workaround xml buffer size issue in some hwloc versions
  • Loading branch information
mergify[bot] authored Jan 19, 2024
2 parents f1feae8 + 21b0fba commit c4c427c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/common/librlist/rhwloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,24 @@ static int init_topo_from_xml (hwloc_topology_t *tp,
const char *xml,
unsigned long flags)
{
if ((topo_init_common (tp, flags) < 0)
|| (hwloc_topology_set_xmlbuffer (*tp, xml, strlen (xml)) < 0)
|| (hwloc_topology_load (*tp) < 0)) {
hwloc_topology_destroy (*tp);
return (-1);
int len = strlen (xml) + 1;

if (topo_init_common (tp, flags) < 0)
return -1;
if (hwloc_topology_set_xmlbuffer (*tp, xml, len) < 0) {
/* In some versions of hwloc/libxml, the NUL character on the XML
* buffer cannot be included in len. Therefore, if set_xmlbuffer fails
* above, retry with len-1.
*/
if (hwloc_topology_set_xmlbuffer (*tp, xml, len - 1) < 0)
goto error;
}
return (0);
if (hwloc_topology_load (*tp) < 0)
goto error;
return 0;
error:
hwloc_topology_destroy (*tp);
return -1;
}

static int topo_restrict (hwloc_topology_t topo)
Expand Down

0 comments on commit c4c427c

Please sign in to comment.