[FFmpeg-devel] [PATCH] idctdsp: make ff_add/put_pixels_clamped function pointers atomic.

Ronald S. Bultje rsbultje at gmail.com
Tue Apr 4 17:10:01 EEST 2017


Hi,

On Tue, Apr 4, 2017 at 10:07 AM, Michael Niedermayer <michael at niedermayer.cc
> wrote:

> On Tue, Apr 04, 2017 at 09:09:36AM -0400, Ronald S. Bultje wrote:
> > This fixes the following tsan warnings when running fate-dnxhr-parse:
> >
> > WARNING: ThreadSanitizer: data race (pid=29917)
> >   Write of size 8 at 0x0000025b12d8 by thread T2 (mutexes: write M1543):
> >     #0 ff_idctdsp_init src/libavcodec/idctdsp.c:313
> (ffmpeg+0x00000044b68e)
> > [..]
> >   Previous write of size 8 at 0x0000025b12d8 by thread T1 (mutexes:
> write M1541):
> >     #0 ff_idctdsp_init src/libavcodec/idctdsp.c:313
> (ffmpeg+0x00000044b68e)
> > ---
> >  libavcodec/idctdsp.c |  8 ++++----
> >  libavcodec/idctdsp.h | 17 +++++++++++++++--
> >  2 files changed, 19 insertions(+), 6 deletions(-)
>
> does this have any performance effect and why do 2 threads write into
> the same variable ?
> It seems rather suspicious that 2 diferent threads write into the same
> pointer


In dnxhd, the initial context is uninitialized and is initialized at
runtime during header parsing (or when bpp changes). So each thread calls
idctdsp_init() once, each of which writes into the same global variable
exactly once.

This patch is a total hack, I openly admit that, I'm just exploring the
bugs and am happy to discuss alternate designs. Some people have expressed
the wish to get rid of the global function pointers which is probably a
good longer-term goal...

Ronald


More information about the ffmpeg-devel mailing list