[FFmpeg-trac] #7446(avcodec:new): x264 init race/corruption
FFmpeg
trac at avcodec.org
Wed Sep 19 09:58:39 EEST 2018
#7446: x264 init race/corruption
-------------------------------------+-------------------------------------
Reporter: lukealonso | Type: defect
Status: new | Priority: normal
Component: avcodec | Version:
Keywords: | unspecified
Blocking: | Blocked By:
Analyzed by developer: 0 | Reproduced by developer: 0
-------------------------------------+-------------------------------------
Summary of the bug:
I have a program that creates many concurrent instances of x264 via
AVCodecContext. Occasionally, I'll get the following output:
{{{
x264 [error]: invalid tune '[RANDOM JUNK]'
}}}
and avcodec_open2 will fail.
I've attached a stripped down program that reproduces the issue, at least
on Ubuntu 16.04.
This appears to happen with all x264 versions, I tried the latest stable
commit, and one from several years ago.
This does *NOT* happen with older FFmpeg versions. I git bisected and
found that the problem started happening on commit:
{{{
[abaa12263e08ae7b2099f00fa4597ae6a86d7a9c] avcodec: Don't lock during open
if the codec has threadsafe init]
}}}
.... which is not surprising, but not terribly helpful in finding what
exactly is happening in X264_init that causes the issue.
Hopefully this is just me being dumb, any pointers would be appreciated.
How to reproduce:
Build enc_test.c:
{{{
gcc -o enc_test enc_test.c -lavcodec -lavformat -lavutil -lpthread
}}}
Run 1-10 times, with num_threads between 4-32, whatever is appropriate for
your machine. Happens more often with higher thread counts. It should
happen early on, so ctrl-c and try again if it hasn't happened with in a
few seconds.
{{{
./enc_test [num_threads]
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7446>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list