[FFmpeg-devel] [RFC] v4l2_m2m: Fix races around freeing data on close

Jorge Ramirez jorge.ramirez-ortiz at linaro.org
Mon Oct 23 13:14:28 EEST 2017


On 10/23/2017 01:47 AM, Mark Thompson wrote:
>> so let's make this work then and fix the SIGSEGV present in master asap (btw this RFC also seg-fault when the above is applied)
> Where does that version segfault?  (It doesn't for me.)

the patch will segfault if the changes below are applied to the baseline.

those changes simulate the case where the client doesnt provide the 
height/width; when that happens, since ffmpeg registers for the v4l2 
kernel event which provides the resolution, ffmpeg will have to dequeue 
the old buffers and queue new ones capable of storing the frame to the 
driver (in the code that is handled by reinit/full_reinit.

note that full_reinit has not been implemented properly (I had to close 
the driver to work around a venus issue ...it is an easy fix once I have 
a driver that works)


>> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
>> index 831fd81..1dd8cf0 100644
>> --- a/libavcodec/v4l2_m2m_dec.c
>> +++ b/libavcodec/v4l2_m2m_dec.c
>> @@ -176,8 +176,8 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
>>        * by the v4l2 driver; this event will trigger a full pipeline reconfig and
>>        * the proper values will be retrieved from the kernel driver.
>>        */
>> -    output->height = capture->height = avctx->coded_height;
>> -    output->width = capture->width = avctx->coded_width;
>> +    output->height = capture->height = 0; //avctx->coded_height;
>> +    output->width = capture->width = 0; //avctx->coded_width;
>>
>>       output->av_codec_id = avctx->codec_id;
>>       output->av_pix_fmt  = AV_PIX_FMT_NONE;



More information about the ffmpeg-devel mailing list