History

avcodec/pthread_slice: Don't use static variable, fix race

ff_slice_thread_init() uses a static variable to hold a function pointer, although the value of said pointer needn't be saved between different runs of this function at all. The reason for this being so is probably that said pointer points to a static function (if used); but storage class specifiers like "static" are not part of the type of an object and so including it in the pointer declaration is wrong (anyway, "static" means different things in both contexts: for the function declaration it affects linkage, for the variable storage duration). Using a static variable here can lead to races, e.g. when initializing VP9 (for which said function pointer was added) and H.264 with slice threading. The latter has the FF_CODEC_CAP_INIT_THREADSAFE flag set and is therefore unaffected by the lock guarding initializations of decoders.

Andreas Rheinhardt committed 5 years ago

Commit 0639f5c1 parent 4e265201 file · +1 −1Browse files

Unified · Split

libavcodec/pthread_slice.c+1−1
@@ -130,7 +130,7 @@ int ff_slice_thread_init(AVCodecContext *avctx) · 129 unmodified lines
130130 {
131131 SliceThreadContext *c;
132132 int thread_count = avctx->thread_count;
133− static void (*mainfunc)(void *);
133+ void (*mainfunc)(void *);
134134
135135 // We cannot do this in the encoder init as the threads are created before
136136 if (av_codec_is_encoder(avctx->codec) &&

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t