This bug was found by Dmitry Vyukov. If two threads may call ff_thread_report_progress at the same time, progress[field] may decrease. For example, suppose progress[field] is 10 and two threads call ff_thread_report_progress to update progress[field] to 11 and 12, respectively. If the second thread acquires progress_mutex first and updates progress[field] to 12, then the first thread will update progress[field] to 11, causing progress[field] to decrease. --- libavcodec/pthread_frame.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index b77dd1e..a43e8fe 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -482,8 +482,10 @@ void ff_thread_report_progress(ThreadFrame *f, int n, int field) av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field); pthread_mutex_lock(&p->progress_mutex); - progress[field] = n; - pthread_cond_broadcast(&p->progress_cond); + if (progress[field] < n) { + progress[field] = n; + pthread_cond_broadcast(&p->progress_cond); + } pthread_mutex_unlock(&p->progress_mutex); } -- 2.7.0.rc3.207.g0ac5344 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel