Opened 4 years ago

Closed 3 years ago

#2450 closed defect (fixed)

Xorg resource leakage

Reported by: raimund Owned by:
Priority: important Component: avdevice
Version: git-master Keywords: x11grab regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:

ffmpeg increases virtual memory of Xorg server.

How to reproduce:

Operating system: CentOS release 6.2 (Final)
ffmpeg releases: 1.1.4, 1.2
configuration: --disable-yasm --enable-gpl --enable-x11grab --enable-version3 --enable-libvo-aacenc

Run
% ffmpeg -f x11grab -s cif -r 25 -i :0.0 /tmp/out.mpg

and monitor X11 client resources by
% xrestop

You will find an <unknown> client constantly increasing X11 server memory.
Batch usage of xrestop indicates leak in category "cursors". 
(Maybe ticket #1738 introduced it?)

Bug does _not_ appear for releases 0.11.3 and 1.0.6!

Change History (4)

comment:1 Changed 4 years ago by cehoyos

  • Component changed from FFmpeg to avdevice
  • Keywords regression added
  • Priority changed from normal to important

Is this also reproducible with current git head?
To make this a valid ticket, please provide the ffmpeg command line together with the complete, uncut console output.

Please use git bisect to find the commit introducing the problem.

comment:2 Changed 4 years ago by raimund

Is reproducible with current git head:

$ ./ffmpeg -f x11grab -s cif -r 25 -i :0.0 /tmp/out.mpg

ffmpeg version N-51680-ge82f562 Copyright (c) 2000-2013 the FFmpeg developers

built on Apr 8 2013 21:24:02 with gcc 4.4.6 (GCC) 20110731 (Red Hat 4.4.6-3)
configuration: --disable-yasm --enable-gpl --enable-x11grab --enable-version3 --enable-libvo-aacenc
libavutil 52. 25.100 / 52. 25.100
libavcodec 55. 2.100 / 55. 2.100
libavformat 55. 1.100 / 55. 1.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 49.100 / 3. 49.100
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100

[x11grab @ 0x9410540] device: :0.0 -> display: :0.0 x: 0 y: 0 width: 352 height: 288
[x11grab @ 0x9410540] shared memory extension found
Input #0, x11grab, from ':0.0':

Duration: N/A, start: 1365491257.958856, bitrate: 81100 kb/s

Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 352x288, 81100 kb/s, 25 tbr, 1000k tbn, 25 tbc

File '/tmp/out.mpg' already exists. Overwrite ? [y/N] y
VBV buffer size not set, muxing may fail
Output #0, mpeg, to '/tmp/out.mpg':

Metadata:

encoder : Lavf55.1.100
Stream #0:0: Video: mpeg1video, yuv420p, 352x288, q=2-31, 200 kb/s, 90k tbn, 25 tbc

Stream mapping:

Stream #0:0 -> #0:0 (rawvideo -> mpeg1video)

Press [q] to stop, ? for help
[swscaler @ 0x9404c00] Warning: data is not aligned! This can lead to a speedloss
frame= 1101 fps= 25 q=31.0 Lsize= 2336kB time=00:00:44.00 bitrate= 434.9kbits/s
video:2322kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.615708%

While ffmpeg is running execute
$ xrestop -b -m 1

I got for the ffmpeg X11 client after ~500 frames:

cursors : 531

and after ~1000 frames:

cursors : 1040

Leak disappers when patching this way:

diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index 6124006..bf88e88 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -361,10 +361,12 @@ paint_mouse_pointer(XImage *image, struct x11grab *s)

if (image->bits_per_pixel != 24 && image->bits_per_pixel != 32)

return;


+/*

c = XCreateFontCursor(dpy, XC_left_ptr);
w = DefaultRootWindow?(dpy);
attr.cursor = c;
XChangeWindowAttributes(dpy, w, CWCursor, &attr);

+*/

=> Revise bugfix #1738.

comment:3 Changed 4 years ago by cehoyos

  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from 1.1.4 to git-master

comment:4 Changed 3 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed

Fixed by Michael.

Note: See TracTickets for help on using tickets.