marranxo
Posts: 29
Joined: Thu Dec 03, 2015 2:16 pm

deadlock in ilclient_change_component_state

Mon Sep 10, 2018 9:58 am

Hi,

I'm running 2 threads and each one has one image_decode tunneled to a resizer to decode jpeg images and convert colorspace (yuv->rgb) , a image_encode to encode decoded images with some OSD and a video_encode encoding image sequences to h264. Both threads run the same code but with different input (each one reads a different jpeg file).

The image_decode tunneled to the resizer has one ilclient instance, the image_encoder has another different ilclient instance and the video_encode also has another different ilclient instance. Same happens in the second thread, 3 ilclient instances.

After some hours/days of working the test program gets stuck and the working treads are both trying to change the state:

First thread.

Code: Select all

#0  0x76f03014 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, 
    expected=1, futex_word=0x76f89394 <vcos_thread_main+12>)
    at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait ([email protected]=0x76f89394 <vcos_thread_main+12>, abstime=0x0)
    at sem_waitcommon.c:115
#2  0x76f03158 in __new_sem_wait_slow (
    [email protected]=0x76f89394 <vcos_thread_main+12>, abstime=0x0)
    at sem_waitcommon.c:282
#3  0x76f031e0 in __new_sem_wait (
    [email protected]=0x76f89394 <vcos_thread_main+12>) at sem_wait.c:29
#4  0x76f73da4 in vcos_semaphore_wait (sem=0x76f89394 <vcos_thread_main+12>)
    at /home/dc4/projects/staging/userland/interface/vcos/pthreads/vcos_platform.h:254
#5  _vcos_thread_sem_wait ()
    at /home/dc4/projects/staging/userland/interface/vcos/pthreads/vcos_platform.h:646
#6  vcos_generic_event_flags_get (flags=0x476e8, bitmask=144, op=5, 
    suspend=4294967295, retrieved_bits=0x7effee4c)
    at /home/dc4/projects/staging/userland/interface/vcos/generic/vcos_generic_event_flags.c:223
#7  0x0001e320 in vcos_event_flags_get (flags=0x476e8, requested_events=144, 
    op=5, suspend=4294967295, retrieved_events=0x7effee4c)
    at /opt/vc/include/interface/vcos/generic/vcos_generic_event_flags.h:118
#8  0x0002141c in ilclient_wait_for_command_complete_dual (comp=0x476d0, 
    command=OMX_CommandStateSet, nData2=3, other=0x0) at ilclient.c:1252
#9  0x00021478 in ilclient_wait_for_command_complete (comp=0x476d0, 
    command=OMX_CommandStateSet, nData2=3) at ilclient.c:1271
#10 0x00020060 in ilclient_change_component_state (comp=0x476d0, 
    state=OMX_StateExecuting) at ilclient.c:748
#11 0x0001bdb8 in omx_h264_encoder::encode (this=0x7effef48, img=..., 
    output=std::vector of length 0, capacity 0)
    at /home/pi/Projects/omx_testing/src/omx_h264_encoder.cpp:89
#12 0x00015940 in main () at /home/pi/Projects/omx_testing/main.cpp:840
Second thread.

Code: Select all

#0  0x76f03014 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, 
    expected=1, futex_word=0x72c00dec)
    at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait ([email protected]=0x72c00dec, abstime=0x0)
    at sem_waitcommon.c:115
#2  0x76f03158 in __new_sem_wait_slow ([email protected]=0x72c00dec, abstime=0x0)
    at sem_waitcommon.c:282
#3  0x76f031e0 in __new_sem_wait ([email protected]=0x72c00dec) at sem_wait.c:29
#4  0x76f73da4 in vcos_semaphore_wait (sem=0x72c00dec)
    at /home/dc4/projects/staging/userland/interface/vcos/pthreads/vcos_platform.h:254
#5  _vcos_thread_sem_wait ()
    at /home/dc4/projects/staging/userland/interface/vcos/pthreads/vcos_platform.h:646
#6  vcos_generic_event_flags_get (flags=0x72c00cd8, bitmask=144, op=5, 
    suspend=4294967295, retrieved_bits=0x735feca4)
    at /home/dc4/projects/staging/userland/interface/vcos/generic/vcos_generic_event_flags.c:223
#7  0x0001e320 in vcos_event_flags_get (flags=0x72c00cd8, 
    requested_events=144, op=5, suspend=4294967295, 
    retrieved_events=0x735feca4)
    at /opt/vc/include/interface/vcos/generic/vcos_generic_event_flags.h:118
#8  0x0002141c in ilclient_wait_for_command_complete_dual (comp=0x72c00cc0, 
    command=OMX_CommandStateSet, nData2=2, other=0x0) at ilclient.c:1252
#9  0x00021478 in ilclient_wait_for_command_complete (comp=0x72c00cc0, 
    command=OMX_CommandStateSet, nData2=2) at ilclient.c:1271
#10 0x00020060 in ilclient_change_component_state (comp=0x72c00cc0, 
    state=OMX_StateIdle) at ilclient.c:748
#11 0x0001dbb4 in omx_jpeg_encoder::encode (this=0x735fee04, img=..., 
    output=std::vector of length 0, capacity 0, quality=95)
    at /home/pi/Projects/omx_testing/src/omx_jpeg_encoder.cpp:139
#12 0x0001558c in main3 (arg=0x0) at /home/pi/Projects/omx_testing/main.cpp:765
#13 0x76ef9fc4 in start_thread (arg=0x735ff450) at pthread_create.c:335

The code is isolated, it's running the same sequence again and again and again. I don't have any callbacks asociated to ilclient except the error calback just printing to stderr, also ilclient it's running its own event handler. Do I have to mutex access to components in different threads? It's ok to run multiple instances of ilclient (I'm using 6 instances, 3x thread)?

Thanks.

Return to “OpenMAX”