[FFmpeg-devel] [PATCH] ffplay: fix a crash caused by aborting the video queue

Marton Balint cus at passwd.hu
Sat Aug 27 12:09:53 CEST 2011


On Sat, 27 Aug 2011, avcoder wrote:

> I fail to understand!
>
> The following "if(is->videoq.abort_request) " will prevent the code
> from going through. so there is no any chance to affect
> VideoState->pictq_windex

Yes, the patch description is probably not entirely correct, sorry, my 
mistake. The thought of changing w_index somehow remained in my mind from 
the time I debugged this.

The main problem with the code is that multiple ALLOC events may occur at 
the same time if we don't pop them from the event queue on abort. If these 
alloc events tries to allocate the same vp, vp->bmp changes (free-d, and 
the then allocated again), I typically got the crash when 
SDL_LockYUVOverlay(vp->bmp) was called from the video thread, after 
SDL_FreeYUVOverlay(vp->bmp) was called from the main thread.

Regards,
   Marton

>
> On Fri, Aug 26, 2011 at 4:06 AM, Marton Balint <cus at passwd.hu> wrote:
>> If the video queue is aborted, we have to pop the pending ALLOC event or wait
>> for the allocation to complete, because the current code assumes that
>> VideoState->pictq_windex does not change until the allocation is complete.
>> ---
>>  ffplay.c |    6 ++++++
>>  1 files changed, 6 insertions(+), 0 deletions(-)
>>
>> diff --git a/ffplay.c b/ffplay.c
>> index 80611e8..8a3e409 100644
>> --- a/ffplay.c
>> +++ b/ffplay.c
>> @@ -1355,6 +1355,12 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_
>>         while (!vp->allocated && !is->videoq.abort_request) {
>>             SDL_CondWait(is->pictq_cond, is->pictq_mutex);
>>         }
>> +        /* if the queue is aborted, we have to pop the pending ALLOC event or wait for the allocation to complete */
>> +        if (is->videoq.abort_request && SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(FF_ALLOC_EVENT)) != 1) {
>> +            while (!vp->allocated) {
>> +                SDL_CondWait(is->pictq_cond, is->pictq_mutex);
>> +            }
>> +        }
>>         SDL_UnlockMutex(is->pictq_mutex);
>>
>>         if (is->videoq.abort_request)
>
> -- 
> -----------------------------------------------------------------------------------------
> My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list