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 <michae...@gmx.at>
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 <michae...@gmx.at>
---

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);
 };

Reply via email to