[FFmpeg-devel] [PATCH] pthread: Avoid crashes/odd behavior caused by spurious wakeups

Michael Niedermayer michaelni at gmx.at
Fri Sep 14 01:51:12 CEST 2012

On Thu, Sep 13, 2012 at 04:34:25PM -0700, Ben Jackson wrote:
> On Fri, Sep 14, 2012 at 12:55:53AM +0200, Michael Niedermayer wrote:
> > 
> > well, the job count can change for each avcodec_thread_execute()
> > i see now its not really helping in simplifying things but it feels
> > more correct to set it to 0 when there are no jobs to be done
> I considered a patch to clean up ThreadContext when it's idle.  Part of
> the reason that spurious wakeups in worker() were hard to figure out is
> that it had all the stale data from the last job and crashed inside the
> decoder.  Cleaning up between executes would move the crash to worker()...
> By that point I knew how to fix the problem so I just fixed it so that
> (hopefully) the stale info in ThreadContext is irrelevant.  But I'll
> submit a patch to clean out ThreadContext in avcodec_thread_park_workers
> if you think it's worthwhile.

i think it would be a good idea

> > > > > +    c->current_execute++;
> > > > 
> > > > signed integer overflow and undefined behavior
> > 
> > ^=1 or unsigned or anything equivalent is fine
> I'll resubmit with that change later tonight.


> > no, the original code is broken and the patch fixes it. I just hoped
> > that a simpler condition would work but it seems thats not the case
> I think something more state-machine like (similar to the frame threading)
> would be easier to understand but it would be a rewrite.

I dont think rewriting the slice threading is worth it. The code
has been there and has been tested and bugfixed since a long time.
while OTOH, the frame thread code has known bugs that havent been
analyzed/debugged yet.

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- 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/20120914/55dfecc4/attachment.asc>

More information about the ffmpeg-devel mailing list