[FFmpeg-devel] Race condition in msmpeg4dec.c?
thesauce at gmail.com
Sat Feb 22 01:01:25 CET 2014
I'm working with a relatively old version of FFMPEG's libraries, and I'm
getting a crash if I try to open a .wmv (WMV3 codec inside) file in two
threads at the same time. It works fine if I open another one beforehand.
So, although I don't have proof because I can't get debug info for this old
version on windows, this hints to a race condition during codec
initialization. The crash is occuring in libavcodec.dll though.
Now, looking at the latest code in msmpeg4dec.c, in
ff_msmpeg4_decode_init() there is a initialization variable:
static volatile int done = 0;
that sticks out as questionable. Is this initialization code write-only?
That is, if two threads execute it at the same time is that fine? Or is the
crash possible if two are doing it at the same time, in which case this
initialization variable isn't thread-safe.
The old code I'm working with has a few similar initialization variables
floating around also, all which seem very un-threadsafe to me.
So my question is, am I off-base about the potential for these kinds of
initialization variables being un-threadsafe? Is there a lock protecting
the work higher up? Or is all that init code safe to execute simultaneously
since it's just writing data to structures?
More information about the ffmpeg-devel