Recently, Tomas Vanek found a bug when investigating a different issue (https://review.openocd.org/c/openocd/+/9126) that when -codeid is not specified for a core, multicore targets will each have the same one on one debug module, leading to errors.
This should be fixed.
This config can be used to recreate it:
target create c0 riscv -chain-position riscv.cpu -rtos hwthread
target create c1 riscv -chain-position riscv.cpu -rtos hwthread
target smp c0 c1