Crash in cuvidCreateDecoder

I have an app that crashes randomly in time but in one place. The call stack is:

#0  0x00007f53ac481228 in  () at /usr/lib/x86_64-linux-gnu/
#1  0x00007f53ac48135b in  () at /usr/lib/x86_64-linux-gnu/
#2  0x00007f53ac4825fb in  () at /usr/lib/x86_64-linux-gnu/
#3  0x00007f53ac46ac05 in  () at /usr/lib/x86_64-linux-gnu/
#4  0x00007f53ac46aea0 in  () at /usr/lib/x86_64-linux-gnu/
#5  0x00007f53ac4528d6 in  () at /usr/lib/x86_64-linux-gnu/
#6  0x00007f53ac45d437 in  () at /usr/lib/x86_64-linux-gnu/
#7  0x00007f53ac45a0df in  () at /usr/lib/x86_64-linux-gnu/
#8  0x00007f53ac455cda in  () at /usr/lib/x86_64-linux-gnu/
#9  0x00007f53ac454ba7 in cuvidCreateDecoder () at /usr/lib/x86_64-linux-gnu/
#10 0x00007f53acb0eb5b in cuvidv4l2_handle_video_sequence_cb(void*, CUVIDEOFORMAT*) () at ///opt/nvidia/deepstream/deepstream-4.0/lib/
#11 0x00007f53ac44f680 in  () at /usr/lib/x86_64-linux-gnu/
#12 0x00007f53ac4a4560 in  () at /usr/lib/x86_64-linux-gnu/
#13 0x00007f53ac48de2b in  () at /usr/lib/x86_64-linux-gnu/
#14 0x00007f53ac48fe06 in  () at /usr/lib/x86_64-linux-gnu/
#15 0x00007f53ac4a4937 in  () at /usr/lib/x86_64-linux-gnu/
#16 0x00007f53ac4a4f98 in  () at /usr/lib/x86_64-linux-gnu/
#17 0x00007f53ac44f41b in  () at /usr/lib/x86_64-linux-gnu/
#18 0x00007f53acb12d64 in cuvidv4l2_dec_enqueue_instream_buffers(v4l2_decoder_context_rec*) () at ///opt/nvidia/deepstream/deepstream-4.0/lib/
#19 0x00007f53acb1309a in cuvidv4l2_dec_thread_func(void*) () at ///opt/nvidia/deepstream/deepstream-4.0/lib/
#20 0x00007f53acb01b30 in thread_wrapper(void*) () at ///opt/nvidia/deepstream/deepstream-4.0/lib/
#21 0x00007f54647c46db in start_thread () at /lib/x86_64-linux-gnu/
#22 0x00007f5462bc471f in clone () at /lib/x86_64-linux-gnu/

That happens while another thread is always deep in gst_element_change_state(… NULL) for a bin that contains a video source reader/parser/decoder.

Do you have any recomendations on how to debug/fix this? Thank you!

**• Hardware Platform - GTX 1080 **
**• DeepStream Version - 4.0.2 **
**• NVIDIA GPU Driver Version (valid for GPU only) - 460.32.03 **

First, deepstream 4.0 is out of date, please upgrade to latest deepstream version DeepStream Getting Started | NVIDIA Developer

From the error log, we can only know something wrong with VID, no way to know why.

Well, updating to DS5 would probably be good, but takes take, so I’d like to postpone that for now :)
There’s some race in my code and I’m not sure updating will fix the issue.

What I’ve noticed is what GST documentation says about gst_element_change_state (which is where that another thread at): “this is racy if the state lock of the parent bin is not taken. The parent bin might’ve just checked the flag in another thread and as the next step proceed to change the child element’s state.”

I confirm, DS5.0.0 fixes that issue.