When oldtail is 0, miEventQueue.events[oldtail - 1] is out of bound.
Created attachment 9351 [details] [review]
patch for this
This patch resolved the problem except the case that the first event enqueued has type DeviceValuator.
this bug has been fixed a while ago. thanks for reporting!