The problem is that node[node_id].cpu_list_p is wrong. When you look at the array again it has two real entries and nothing more:
(gdb) p node[0] $20 = {node_id = 0, MBs_total = 65266, MBs_free = 1510, CPUs_total = 2000, CPUs_free = 1144, magnitude = 1727440, distance = 0x304a3a41850 "\n(\032\n\244~", cpu_list_p = 0x304a3a41810} (gdb) p node[1] $21 = {node_id = 8, MBs_total = 65337, MBs_free = 1734, CPUs_total = 2000, CPUs_free = 1049, magnitude = 1818966, distance = 0x304a3a418b0 "(\n\032\n\244~", cpu_list_p = 0x304a3a41870} (gdb) p node[2] $22 = {node_id = 1820693536, MBs_total = 33, MBs_free = 3318460192688, CPUs_total = 24, CPUs_free = 1839495593, magnitude = 33, distance = 0x1111111111111111 <error: Cannot access memory at address 0x1111111111111111>, cpu_list_p = 0x1111111111111111} (gdb) p node[3] $23 = {node_id = 286331153, MBs_total = 33, MBs_free = 3318460192752, CPUs_total = 8, CPUs_free = 1842299472, magnitude = 33, distance = 0x101 <error: Cannot access memory at address 0x101>, cpu_list_p = 0x7ea40a1a0e08 <main_arena+96>} (gdb) p node[4] $24 = {node_id = 1867659328, MBs_total = 33, MBs_free = 3318460192816, CPUs_total = 24, CPUs_free = 1882184320, magnitude = 33, distance = 0x1111111111111111 <error: Cannot access memory at address 0x1111111111111111>, cpu_list_p = 0x1111} (gdb) p node[5] $25 = {node_id = 0, MBs_total = 33, MBs_free = 139243009222666, CPUs_total = 139243009216008, CPUs_free = 1898775676, magnitude = 33, distance = 0x304a3a41890 "", cpu_list_p = 0x18} (gdb) p node[6] $26 = {node_id = 3689421645304561696, MBs_total = 33, MBs_free = 0, CPUs_total = 1229782938247299072, CPUs_free = 286331153, magnitude = 33, distance = 0x7ea40a1a0a28 <_IO_wide_data_2+264> "", cpu_list_p = 0x7ea40a1a0e08 <main_arena+96>} (gdb) p node[7] $27 = {node_id = 3546150882158837792, MBs_total = 33, MBs_free = 257, CPUs_total = 267, CPUs_free = 288230377091498008, magnitude = 33, distance = 0x304a3a41910 "\001\001", cpu_list_p = 0x8} (gdb) p node[8] $28 = {node_id = 303211223003168792, MBs_total = 33, MBs_free = 257, CPUs_total = 265, CPUs_free = 288230377024389144, magnitude = 33, distance = 0x2f69 <error: Cannot access memory at address 0x2f69>, cpu_list_p = 0x0}
We essentially do an out of bounds to the array at index [8] where cpu_list_p = 0x0 and that triggers the SEGV
We actually do NOT want node[node_id]
Instead we'd need to iterate the node array entries, and pick that entry which has nodes[x].node_id == node_id.
The problem is that node[node_ id].cpu_ list_p is wrong.
When you look at the array again it has two real entries and nothing more:
(gdb) p node[0] 111>, cpu_list_p = 0x1111111111111111} 111>, cpu_list_p = 0x1111} 1696, MBs_total = 33, MBs_free = 0, CPUs_total = 122978293824729 9072, CPUs_free = 286331153, magnitude = 33, data_2+ 264> "", cpu_list_p = 0x7ea40a1a0e08 <main_arena+96>} 7792, MBs_total = 33, MBs_free = 257, CPUs_total = 267, CPUs_free = 288230377091498008, magnitude = 33, distance = 0x304a3a41910 "\001\001",
$20 = {node_id = 0, MBs_total = 65266, MBs_free = 1510, CPUs_total = 2000, CPUs_free = 1144, magnitude = 1727440, distance = 0x304a3a41850 "\n(\032\n\244~", cpu_list_p = 0x304a3a41810}
(gdb) p node[1]
$21 = {node_id = 8, MBs_total = 65337, MBs_free = 1734, CPUs_total = 2000, CPUs_free = 1049, magnitude = 1818966, distance = 0x304a3a418b0 "(\n\032\n\244~", cpu_list_p = 0x304a3a41870}
(gdb) p node[2]
$22 = {node_id = 1820693536, MBs_total = 33, MBs_free = 3318460192688, CPUs_total = 24, CPUs_free = 1839495593, magnitude = 33,
distance = 0x1111111111111111 <error: Cannot access memory at address 0x1111111111111
(gdb) p node[3]
$23 = {node_id = 286331153, MBs_total = 33, MBs_free = 3318460192752, CPUs_total = 8, CPUs_free = 1842299472, magnitude = 33,
distance = 0x101 <error: Cannot access memory at address 0x101>, cpu_list_p = 0x7ea40a1a0e08 <main_arena+96>}
(gdb) p node[4]
$24 = {node_id = 1867659328, MBs_total = 33, MBs_free = 3318460192816, CPUs_total = 24, CPUs_free = 1882184320, magnitude = 33,
distance = 0x1111111111111111 <error: Cannot access memory at address 0x1111111111111
(gdb) p node[5]
$25 = {node_id = 0, MBs_total = 33, MBs_free = 139243009222666, CPUs_total = 139243009216008, CPUs_free = 1898775676, magnitude = 33, distance = 0x304a3a41890 "", cpu_list_p = 0x18}
(gdb) p node[6]
$26 = {node_id = 368942164530456
distance = 0x7ea40a1a0a28 <_IO_wide_
(gdb) p node[7]
$27 = {node_id = 354615088215883
cpu_list_p = 0x8}
(gdb) p node[8]
$28 = {node_id = 303211223003168792, MBs_total = 33, MBs_free = 257, CPUs_total = 265, CPUs_free = 288230377024389144, magnitude = 33,
distance = 0x2f69 <error: Cannot access memory at address 0x2f69>, cpu_list_p = 0x0}
We essentially do an out of bounds to the array at index [8] where cpu_list_p = 0x0 and that triggers the SEGV
We actually do NOT want node[node_id]
Instead we'd need to iterate the node array entries, and pick that entry which has nodes[x].node_id == node_id.