I would risk assuming your code is overflowing the array somewhere (or causing Python to do this).
You will find that debugging will be difficult if you cannot reliably reproduce it, so you can explicitly sow the random number generator and try to find a seed with which you can reproduce the damage. You may also find that with a tool like valgrind , itβs useful to keep track of when you write within the selection - perhaps more so when you can play it every time.
source share