[FFmpeg-devel] Race condition in msmpeg4dec.c?

Michael Niedermayer michaelni at gmx.at
Sun Feb 23 02:11:49 CET 2014


On Fri, Feb 21, 2014 at 07:01:25PM -0500, Malcolm Bechard wrote:
> Hey,
> 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?

theres a lock thats used automatically, see ff_lock_avcodec()
also the code possibly is thread safe without it in upto date ffmpeg

also please test with the latest version, the behavior of old
versions is just wasting your time

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140223/1bf26981/attachment.asc>


More information about the ffmpeg-devel mailing list