Opened 6 years ago

Closed 4 years ago

#7385 closed defect (fixed)

Memory leak using decode vp8

Reported by: a Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: vp8 leak
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

 valgrind --tool=memcheck --leak-check=full --log-file=webm_log.txt ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -y -i /media//vp8/vp8_rev0_InterFrame_NewMV_Anim.webm -f md5 ffmpeg_vaapi.md5

full output

ffmpeg version N-91600-g5423fe2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --enable-vaapi --prefix=/opt/X11R7/ffmpeg_mainline --enable-nonfree --enable-shared --enable-libmfx --enable-gpl --enable-libx264 --enable-libx265
  libavutil      56. 19.100 / 56. 19.100
  libavcodec     58. 22.101 / 58. 22.101
  libavformat    58. 17.101 / 58. 17.101
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 26.100 /  7. 26.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[AVHWDeviceContext @ 0xba139c0] Opened VA display via DRM device /dev/dri/renderD128.
[AVHWDeviceContext @ 0xba139c0] libva: VA-API version 1.2.0
[AVHWDeviceContext @ 0xba139c0] libva: va_getDriverName() returns 0
[AVHWDeviceContext @ 0xba139c0] libva: User requested driver 'iHD'
[AVHWDeviceContext @ 0xba139c0] libva: Trying to open /opt/X11R7/vpg_driver/lib/dri//iHD_drv_video.so
[AVHWDeviceContext @ 0xba139c0] libva: Found init function __vaDriverInit_1_2
[AVHWDeviceContext @ 0xba139c0] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0xba139c0] Initialised VAAPI connection: version 1.2
[AVHWDeviceContext @ 0xba139c0] Unknown driver "Intel iHD driver - 2.0.0", assuming standard behaviour.
Input #0, matroska,webm, from '/media//vp8/vp8_rev0_InterFrame_NewMV_Anim.webm':
  Metadata:
    encoder         : vpxenc v0.9.6
  Duration: 00:00:00.07, start: 0.000000, bitrate: 106 kb/s
    Stream #0:0(eng): Video: vp8, 1 reference frame, yuv420p(progressive), 32x32, SAR 1:1 DAR 1:1, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[graph 0 input from stream 0:0 @ 0xbca8140] w:32 h:32 pixfmt:nv12 tb:1/1000 fr:30/1 sar:1/1 sws_param:flags=2
Output #0, md5, to 'ffmpeg_vaapi.md':
  Metadata:
    encoder         : Lavf58.17.101
    Stream #0:0(eng): Video: rawvideo, 1 reference frame (NV12 / 0x3231564E), nv12, 32x32 [SAR 1:1 DAR 1:1], q=2-31, 368 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc58.22.101 rawvideo
[vp8 @ 0xbac3780] Failed to end picture decode issue: 23 (internal decoding error).
Error while decoding stream #0:0: Input/output error
No more output streams to write to, finishing.
frame=    1 fps=0.0 q=-0.0 Lsize=       0kB time=00:00:00.03 bitrate=   8.9kbits/s speed=0.068x
video:2kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/media//vp8/vp8_rev0_InterFrame_NewMV_Anim.webm):
  Input stream #0:0 (video): 2 packets read (522 bytes); 1 frames decoded;
  Total: 2 packets (522 bytes) demuxed
Output file #0 (ffmpeg_vaapi.md):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (1536 bytes);
  Total: 1 packets (1536 bytes) muxed
[AVIOContext @ 0xbabf840] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 0xba69840] Statistics: 882 bytes read, 0 seeks

webm_log.txt

==3114== 512 bytes in 1 blocks are definitely lost in loss record 7 of 11
==3114==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3114==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3114==    by 0x6021056: ??? (in /opt/X11R7/ffmpeg_mainline/lib/libavcodec.so.58.22.101)
==3114==    by 0x6030934: ??? (in /opt/X11R7/ffmpeg_mainline/lib/libavcodec.so.58.22.101)
==3114==    by 0x60B8540: ??? (in /opt/X11R7/ffmpeg_mainline/lib/libavcodec.so.58.22.101)
==3114==    by 0x5F1E9C2: ??? (in /opt/X11R7/ffmpeg_mainline/lib/libavcodec.so.58.22.101)
==3114==    by 0x7CBE6B9: start_thread (pthread_create.c:333)
==3114==    by 0x7FDB41C: clone (clone.S:109)
==3114==
==3114== LEAK SUMMARY:
==3114==    definitely lost: 512 bytes in 1 blocks
==3114==    indirectly lost: 0 bytes in 0 blocks
==3114==      possibly lost: 0 bytes in 0 blocks
==3114==    still reachable: 77,847 bytes in 15 blocks
==3114==         suppressed: 0 bytes in 0 blocks

Change History (11)

comment:1 by Carl Eugen Hoyos, 6 years ago

Keywords: memory removed
Version: unspecifiedgit-master

Please recompile without --enable-shared and post a more useful valgrind output using ffmpeg_g.

Last edited 6 years ago by Carl Eugen Hoyos (previous) (diff)

comment:2 by Carl Eugen Hoyos, 6 years ago

And please confirm if this issue is vaapi-related.

comment:3 by Jun Zhao, 6 years ago

Also please upload or attached the vp8_rev0_InterFrame_NewMV_Anim.webm file for this issue

comment:4 by Linjie.Fu, 6 years ago

This issue could be reproduced by vp80-02-inter-1418.ivf which is available:
https://github.com/webmproject/vp8-test-vectors/blob/master/vp80-02-inter-1418.ivf

It seems that decoding failures of function "vaEndPicture" lead to the error returns without releasing the slice_buffers.

A patch has been commited for this issue.

commit: bd9830712604a7463432c4c09a5c41903eb2a628

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index d0a6b5817d..700cd5c681 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -216,6 +216,11 @@  fail_with_picture:
 fail:
     ff_vaapi_decode_destroy_buffers(avctx, pic);
 fail_at_end:
+    pic->nb_param_buffers = 0;
+    pic->nb_slices        = 0;
+    pic->slices_allocated = 0;
+    av_freep(&pic->slice_buffers);
+
     return err;
 }

The decoding failure is caused by iHD driver. i965 driver works well on this clip.

Will report an issue on iHD driver.

in reply to:  4 comment:5 by Carl Eugen Hoyos, 6 years ago

Replying to fulinjie:

A patch has been commited for this issue.

commit: bd9830712604a7463432c4c09a5c41903eb2a628

Which repository is this supposed to be?

comment:7 by Linjie.Fu, 6 years ago

Decoding failure reported in:
https://github.com/intel/media-driver/issues/317

It seems that a patch has been committed which could solve the decoding failure:
https://patchwork.ffmpeg.org/patch/9943/

comment:9 by Carl Eugen Hoyos, 4 years ago

Component: undeterminedavcodec
Keywords: vp8 added

comment:10 by Carl Eugen Hoyos, 4 years ago

Is this still reproducible?

comment:11 by Carl Eugen Hoyos, 4 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.