[FFmpeg-cvslog] ffmpeg: fix deadlock regression in threading error handing

Sergey git at videolan.org
Fri Jun 27 17:57:04 CEST 2014


ffmpeg | branch: master | Sergey <sergemp at mail.ru> | Fri Jun 27 10:00:53 2014 +0400| [6d2df3c00a7899e9c06e3a460d64e4d0ccde0fae] | committer: Michael Niedermayer

ffmpeg: fix deadlock regression in threading error handing

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.

Reviewed-by: Nicolas George <george at nsup.org>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d2df3c00a7899e9c06e3a460d64e4d0ccde0fae
---

 ffmpeg.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 2c17525..3d23ee6 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;
 }



More information about the ffmpeg-cvslog mailing list