[vlc-devel] [PATCH] decoder: fix race

Rémi Denis-Courmont remi at remlab.net
Tue Mar 31 10:39:30 CEST 2015


Le 2015-03-31 10:43, Thomas Guillem a écrit :
> It happens when an input wait for a decoder that has not decoded any
> data yet.

This patch trivially deadlocks.

> ---
>  src/input/decoder.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index 76c4038..6769279 100644
> --- a/src/input/decoder.c
> +++ b/src/input/decoder.c
> @@ -1435,11 +1435,18 @@ static void *DecoderThread( void *p_data )
>                  break;
>              }
>
> +            vlc_mutex_lock( &p_owner->lock );
>              p_owner->b_idle = true;
> +            vlc_cond_signal( &p_owner->wait_acknowledge );
> +            vlc_mutex_unlock( &p_owner->lock );
> +
>              vlc_fifo_Wait( p_owner->p_fifo );
> +
>              /* Make sure there is no cancellation point other than
> this one^^.
>               * If you need one, be sure to push cleanup of p_block. 
> */
> +            vlc_mutex_lock( &p_owner->lock );
>              p_owner->b_idle = false;
> +            vlc_mutex_unlock( &p_owner->lock );
>          }
>
>          p_block = vlc_fifo_DequeueUnlocked( p_owner->p_fifo );

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list