From 66d8598f9f6e0315367dda36999180b3b78c909a Mon Sep 17 00:00:00 2001 From: XMRig <support@xmrig.com> Date: Mon, 5 Aug 2019 21:55:52 +0700 Subject: [PATCH] #1092 Fixed crash if use wrong affinity on NUMA systems. --- src/crypto/common/VirtualMemory.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/crypto/common/VirtualMemory.cpp b/src/crypto/common/VirtualMemory.cpp index 5f7c45512..081b6c0fa 100644 --- a/src/crypto/common/VirtualMemory.cpp +++ b/src/crypto/common/VirtualMemory.cpp @@ -62,15 +62,18 @@ uint32_t xmrig::VirtualMemory::bindToNUMANode(int64_t affinity) LOG_WARN("CPU #%02u warning: \"can't bind memory\"", puId); } - hwloc_obj_t node = nullptr; - uint32_t nodeId = 0; + uint32_t nodeId = 0; - while ((node = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, node)) != nullptr) { - if (hwloc_bitmap_intersects(node->cpuset, pu->cpuset)) { - nodeId = node->os_index; + if (pu) { + hwloc_obj_t node = nullptr; - break; - } + while ((node = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, node)) != nullptr) { + if (hwloc_bitmap_intersects(node->cpuset, pu->cpuset)) { + nodeId = node->os_index; + + break; + } + } } hwloc_topology_destroy(topology);