Your message dated Mon, 4 Jan 2016 00:35:15 +0100
with message-id <[email protected]>
and subject line Re: Bug#809779: libavutil-dev: Memory Leak in buffer
has caused the Debian Bug report #809779,
regarding libavutil-dev: Memory Leak in buffer
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
809779: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809779
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: libavutil-dev
Version: 6:10.1-1~bpo70+1
Severity: important
Tags: patch

There is a memory leak that leads to players using libav hogging memory like
crazy until RAM and Swap is full and OOM Killer kicks in when playing back
streaming media.

This bug was reported here for mpv and turned out to be a memory leak in 
libav:
https://github.com/mpv-player/mpv/issues/1204

It is fixed in later releases though the wheezy-backports version still suffers
from it



-- System Information:
Debian Release: 7.9
  APT prefers oldstable
  APT policy: (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.18.16 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libavutil-dev depends on:
ii  libavutil53  6:10.1-1~bpo70+1

libavutil-dev recommends no packages.

libavutil-dev suggests no packages.

-- no debconf information
From: Michael Niedermayer <[email protected]>
Date: Sun, 17 Mar 2013 17:36:16 +0000 (+0100)
Subject: avutil/buffer: Fix race in pool.
X-Git-Tag: n2.0~2533
X-Git-Url: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff_plain;h=cea3a63ba3d89d8403eef008f7a7c54d645cff70;hp=73ef12757b9471474bfebda20792448e9bc4e3cc

avutil/buffer: Fix race in pool.

This race will always happen sooner or later in a multi-threaded
environment and it will over time lead to OOM.
This fix works by spinning, there are other ways by which this
can be fixed, like simply detecting the issue after it happened
and freeing the over-allocated memory or simply using a mutex.

Signed-off-by: Michael Niedermayer <[email protected]>
---

Index: libav-10.1/libavutil/buffer.c
===================================================================
--- libav-10.1.orig/libavutil/buffer.c	2014-05-10 16:18:15.000000000 +0000
+++ libav-10.1/libavutil/buffer.c	2016-01-03 22:28:38.683806653 +0000
@@ -307,6 +307,7 @@
     ret->buffer->free   = pool_release_buffer;
 
     avpriv_atomic_int_add_and_fetch(&pool->refcount, 1);
+    avpriv_atomic_int_add_and_fetch(&pool->nb_allocated, 1);
 
     return ret;
 }
@@ -318,6 +319,11 @@
 
     /* check whether the pool is empty */
     buf = get_pool(pool);
+    if (!buf && pool->refcount <= pool->nb_allocated) {
+        while (!buf && avpriv_atomic_int_get(&pool->refcount) <= avpriv_atomic_int_get(&pool->nb_allocated))
+            buf = get_pool(pool);
+    }
+
     if (!buf)
         return pool_alloc_buffer(pool);
 
Index: libav-10.1/libavutil/buffer_internal.h
===================================================================
--- libav-10.1.orig/libavutil/buffer_internal.h	2014-05-10 16:18:15.000000000 +0000
+++ libav-10.1/libavutil/buffer_internal.h	2016-01-03 22:08:03.000000000 +0000
@@ -85,6 +85,8 @@
      */
     volatile int refcount;
 
+    volatile int nb_allocated;
+
     int size;
     AVBufferRef* (*alloc)(int size);
 };

--- End Message ---
--- Begin Message ---
Version: 6:11.1-1

Hi Leszek,

On 03.01.2016 23:55, Leszek Lesner (Web.de) wrote:
> There is a memory leak that leads to players using libav hogging memory like
> crazy until RAM and Swap is full and OOM Killer kicks in when playing back
> streaming media.
> 
> This bug was reported here for mpv and turned out to be a memory leak in 
> libav:
> https://github.com/mpv-player/mpv/issues/1204
> 
> It is fixed in later releases though the wheezy-backports version still 
> suffers
> from it

Libav has been removed from testing, so I doubt that there will be any
more backports of it.
But since this is fixed in Jessie, you could just upgrade to that.
I'm hence closing this bug.

On 03.01.2016 23:55, Leszek Lesner (Web.de) wrote:
> From: Michael Niedermayer <[email protected]>
> Date: Sun, 17 Mar 2013 17:36:16 +0000 (+0100)
> Subject: avutil/buffer: Fix race in pool.
> X-Git-Tag: n2.0~2533
> X-Git-Url: 
> http://git.videolan.org/?p=ffmpeg.git;a=commitdiff_plain;h=cea3a63ba3d89d8403eef008f7a7c54d645cff70;hp=73ef12757b9471474bfebda20792448e9bc4e3cc
> 
> avutil/buffer: Fix race in pool.
> 
> This race will always happen sooner or later in a multi-threaded
> environment and it will over time lead to OOM.
> This fix works by spinning, there are other ways by which this
> can be fixed, like simply detecting the issue after it happened
> and freeing the over-allocated memory or simply using a mutex.
> 
> Signed-off-by: Michael Niedermayer <[email protected]>

This is a patch from FFmpeg that was never part of Libav.
The commit fixing this there is [1].

Best regards,
Andreas


1: 
https://git.libav.org/?p=libav.git;a=commitdiff;h=fbd6c97f9ca858140df16dd07200ea0d4bdc1a83

--- End Message ---

Reply via email to