Skip to content

likwid-topology segfault in affinity_finalize on Raspberry Pi 4 (ARMv8)

Created by: Tobi29

Problem

Using a checkout of 99b0d239 (also happens with the 5.0.1 release) compiled for a Raspberry Pi 4 causes both likwid-topology and likwid-pin (as far as I can tell due to the same issue) to segfault after execution.

As far as I can tell this is probably a similar problem to #228.

Debugging

Debugging the code reveals that there is an out of bounds write to the domains array in affinity_init, which corrupts domains[0].tag ({mlen = 18, slen = 1, data = 0x55555b6f60 "N"} -> {mlen = 18, slen = 1, data = 0x55555b6f60 "@p[UU"}) and one way or another causes the call to free done at the end to crash.

The debug output shows that it seems to think 2 domains will be created, but actually 3 end up being made:

DEBUG - [affinity_init:304] Affinity: Socket domains 1
DEBUG - [affinity_init:312] Affinity: NUMA domains 0
DEBUG - [affinity_init:315] Affinity: CPUs per socket 4
DEBUG - [affinity_init:340] Affinity: All domains 2
DEBUG - [affinity_init:353] Affinity domain N: 4 HW threads on 4 cores
DEBUG - [affinity_init:392] Affinity domain S0: 4 HW threads on 4 cores
DEBUG - [affinity_init:491] Affinity domain M0: 4 HW threads on 4 cores

Running likwid-pin -p shows this corrupted string:

Domain  �:�U:
        0,1,2,3

Domain S0:
        0,1,2,3

[1]    6056 segmentation fault (core dumped)  likwid-pin -p

Details