
Can't you emulate this behaviour with signals different than images ? (say random signal of 64*64*64*3 samples).
I wish I could, but this behaviour only shows up on this peculiar data set :( If the process does not
require a long processing time (say a couple of minutes), then you may be able to use massif tool from valgrind, which may be helpful to detect too many INCREF. For DECREF, then the default memory checker from valgrind should be useful as well.
If it does take only a couple of minutes, it is then relatively easy to "bisect" the code to spot the error (once you get through the C level, it is easy to see the problem, if you can reproduce it, in my experience).
Unfortunately, the process is very long, there are several optimizations in the process, the whole thing in a EM-like algorithm, and the crash does not occur with the first image, it is later. Matthieu