Midi bug in Cubase? EDIT: found the bug in my code

We’re experiencing a mysterious bug with Cubase (8.0.35.565, on OS X 10.11.6, using an in-house in-development VST3 plugin) , which I have a strong guess as to what it is but sadly it only reproduces sporadically, which makes it hard to debug so I can’t really know for sure, hence I’m sharing my guess here and looking for feedback…

My guess is that in Cubase, processBlock sometimes gets midi events in times that don’t correspond to the times of the buffer currently processed - either past or future times but not at the time of the block.

Question: Was I right to expect the midi events which processBlock gets to correspond its time?

My naive loop was generating the samples one by one and handed the midi events at those times in the same loop. And so it missed events out of those times and resulted in stuck midi keys etc.

Does this make sense? Did anyone else face with this problem?
I’ll update if I get more info / verify that this is indeed the bug…

Cheers, Yair

Apparently my guess was totally wrong and Cubase is fine. I just didn’t initialize a variable of the sustain pedal state…