Hi,

when running fate-hevc under valgrind + memory poisoning, I ran into
this issue when running with THREAD_TYPE=slice and THREADS>1.

pthread is not my forte at all, and I'm not sure I'm handling the
thread/... signalling correctly before freeing the leaking variables.

-- 
Christophe
From 1c4004c78c0b33ad2d30d6ef8baf5eb099c5b1eb Mon Sep 17 00:00:00 2001
From: Christophe Gisquet <christophe.gisq...@gmail.com>
Date: Thu, 5 Feb 2015 16:00:11 +0100
Subject: [PATCH] lavc/pthread_slice: release entries

When calling ff_alloc_entries, a number of entries are created.
They are never freed, as running fate with slice threading and
several frames on e.g. fate-hevc-conformance-ENTP_A_Qualcomm_1
would show.
---
 libavcodec/pthread_slice.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index b948e16..a6d3b0f 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -112,14 +112,29 @@ void ff_slice_thread_free(AVCodecContext *avctx)
     pthread_mutex_lock(&c->current_job_lock);
     c->done = 1;
     pthread_cond_broadcast(&c->current_job_cond);
+    for (i = 0; i < c->thread_count; i++)
+        pthread_cond_broadcast(&c->progress_cond[i]);
     pthread_mutex_unlock(&c->current_job_lock);
 
     for (i=0; i<avctx->thread_count; i++)
          pthread_join(c->workers[i], NULL);
 
+    for (i = 0; i < c->thread_count; i++) {
+        pthread_mutex_destroy(&c->progress_mutex[i]);
+        pthread_cond_destroy(&c->progress_cond[i]);
+    }
+
     pthread_mutex_destroy(&c->current_job_lock);
     pthread_cond_destroy(&c->current_job_cond);
     pthread_cond_destroy(&c->last_job_cond);
+
+    if (c->entries)
+        av_freep(&c->entries);
+    if (c->progress_mutex)
+        av_freep(&c->progress_mutex);
+    if (c->progress_cond)
+        av_freep(&c->progress_cond);
+
     av_freep(&c->workers);
     av_freep(&avctx->internal->thread_ctx);
 }
-- 
1.9.2.msysgit.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to