NVJpeg: CUDA Runtime failure: [an illegal memory access was encountered]

Hello. I’m using unchanged code from: nvJPEG-Decoder-MultipleInstances example.

It works in a loop. Everything is good for a few hours, but then it fails randomly (on different images) with error:
CUDA Runtime failure: [an illegal memory access was encountered]

Usually it happens on line 144:
CHECK_CUDA(cudaEventSynchronize(per_thread_params.decode_events[buffer_indices[thread_idx]]));
And after that NVJpeg dies:
NVJPEG failure: #6 for all calls after.

But sometimes fail appears on lines 146 or 149, seems randomly.

I checked everything I could, but everything looks good: enough of memory, all ok with GPU, images are good and etc.
If I use only 1 thread everything work. So seems problem with threads, but I can’t understand where. Thread pool code is unchanged and looks good.

What can I check to understand problem better?