[FFmpeg-devel] [PATCH] ffmpeg: fix deadlock regression in threading error handing
Michael Niedermayer
michaelni at gmx.at
Fri Jun 27 17:56:52 CEST 2014
On Fri, Jun 27, 2014 at 05:20:10PM +0200, Nicolas George wrote:
> Le nonidi 9 messidor, an CCXXII, Sergey a écrit :
> > Commit fc9c857c introduced deadlock regression when processing too many inputs:
> > ffmpeg $(seq -f " -f lavfi -i aevalsrc=0:d=%.0f" 70) -vf concat=n=70:v=0:a=1 -f null -
> > Happens for different number of inputs, depending on available memory size,
> > overcommit settings, ulimits, etc. Easily noticeable for 32-bit builds,
> > that exhaust address space allocating 8-10 MB stack for each thread.
> > Earlier ffmpeg versions exited with unhelpful "Conversion failed!" message.
> >
> > This patch fixes both problems: it frees the queue to prevent deadlock
> > and adds a meaningful error message if pthread_create() fails.
> >
> > ---
> > diff --git a/ffmpeg.c b/ffmpeg.c
> > index 2c17525..ce4b8f5 100644
> > --- a/ffmpeg.c
> > +++ b/ffmpeg.c
> > @@ -3237,8 +3237,11 @@ static int init_input_threads(void)
> > if (ret < 0)
> > return ret;
> >
> > - if ((ret = pthread_create(&f->thread, NULL, input_thread, f)))
> > + if ((ret = pthread_create(&f->thread, NULL, input_thread, f))) {
> > + av_log(NULL, AV_LOG_ERROR, "pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret));
> > + av_thread_message_queue_free(&f->in_thread_queue);
> > return AVERROR(ret);
> > + }
> > }
> > return 0;
> > }
>
> I am not maintainer of ffmpeg.c but responsible for commit fc9c857c, and as
> such I say this looks correct. free_input_threads() try to drain the queues,
> and it will not be able to if there is no sending thread.
applied
thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140627/bbe6f84c/attachment.asc>
More information about the ffmpeg-devel
mailing list