Opened 12 years ago

Closed 11 years ago

#1900 closed defect (fixed)

h264: memleak with threads > 1

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

Description

http://www.datafilehost.com/download-d3ea3b83.html

C:\>ffmpeg -i h264.avi
ffmpeg version N-46283-g1475815 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov  2 2012 02:31:20 with gcc 4.5.0 (GCC) 20100414 (Fedora MinGW 4.5.
0-1.fc14)
  configuration: --prefix=/var/www/users/research/ffmpeg/snapshots/build --arch=
x86 --target-os=mingw32 --cross-prefix=i686-pc-mingw32- --cc='ccache i686-pc-min
gw32-gcc' --enable-w32threads --enable-memalign-hack --enable-runtime-cpudetect
--enable-cross-compile --enable-static --disable-shared --extra-libs='-lws2_32 -
lwinmm -lpthread' --extra-cflags='--static -I/var/www/users/research/ffmpeg/snap
shots/build/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/s
napshots/build/lib' --enable-bzlib --enable-zlib --enable-gpl --enable-version3
--enable-nonfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-
libvorbis --enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      52.  1.100 / 52.  1.100
  libavcodec     54. 70.100 / 54. 70.100
  libavformat    54. 35.100 / 54. 35.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 21.106 /  3. 21.106
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
[h264 @ 0x1edcac0] missing picture in access unit with size 1941
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 2377
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 2090
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 2305
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 3280
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 2963
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 2624
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] illegal log2_max_frame_num 50
[h264 @ 0x1edcac0] missing picture in access unit with size 2937
[h264 @ 0x1edcac0] illegal log2_max_frame_num 50
    Last message repeated 1 times
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] sps_id out of range
[h264 @ 0x1edcac0] missing picture in access unit with size 4221
[h264 @ 0x1edcac0] sps_id out of range
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 3 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 4270
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 3875
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] slice type too large (2) at 0 0
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] sps_id out of range
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 4394
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 4743
[h264 @ 0x1edcac0] Partitioned H.264 support is incomplete
[h264 @ 0x1edcac0] missing picture in access unit with size 5338
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 6106
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] sps_id (32) out of range
[h264 @ 0x1edcac0] missing picture in access unit with size 5938
[h264 @ 0x1edcac0] sps_id (32) out of range
    Last message repeated 1 times
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 5345
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 1 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] too many reference frames
    Last message repeated 1 times
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] sps_id out of range
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 5498
[h264 @ 0x1edcac0] Partitioned H.264 support is incomplete
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 10 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] Partitioned H.264 support is incomplete
[h264 @ 0x1edcac0] sps_id out of range
[h264 @ 0x1edcac0] missing picture in access unit with size 5630
[h264 @ 0x1edcac0] sps_id out of range
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 5714
[h264 @ 0x1edcac0] non-existing PPS 2 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] sps_id out of range
    Last message repeated 1 times
[h264 @ 0x1edcac0] missing picture in access unit with size 5525
[h264 @ 0x1edcac0] sps_id out of range
    Last message repeated 1 times
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] slice type too large (2) at 0 0
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] missing picture in access unit with size 5623
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] FMO not supported
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] FMO not supported
[h264 @ 0x1edcac0] non-existing PPS 227 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] get_buffer() failed (-12 0 0)
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] sps_id out of range
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] illegal POC type 7
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] illegal POC type 7
    Last message repeated 1 times
[h264 @ 0x1edcac0] slice type too large (3) at 0 0
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] non-existing PPS 3 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] non-existing PPS 6 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 13 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] non-existing PPS 10 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] Partitioned H.264 support is incomplete
[h264 @ 0x1edcac0] missing picture in access unit with size 5668
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] sps_id (32) out of range
[h264 @ 0x1edcac0] missing picture in access unit with size 5753
[h264 @ 0x1edcac0] sps_id (32) out of range
    Last message repeated 1 times
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 5903
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 6 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] non-existing PPS referenced
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] non-existing PPS 0 referenced
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] missing picture in access unit with size 5680
[h264 @ 0x1edcac0] no frame!
[h264 @ 0x1edcac0] get_buffer() failed (-12 0 0)
[h264 @ 0x1edcac0] decode_slice_header error
[h264 @ 0x1edcac0] no frame!
Input #0, avi, from 'h264.avi':
  Duration: 00:00:12.64, start: 0.000000, bitrate: 788 kb/s
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 19968x3808, 12.33 fps
, 23.98 tbr, 23.97 tbn, 47.94 tbc
At least one output file must be specified

if I block mem request from ffmpeg I get crash

(gdb) r -i h264.avi
Starting program: d:\mingw\msys\1.0\ffmpeg-head-4f92d31\ffmpeg_g.exe -i h264.avi

[New Thread 200.0x70c]
ffmpeg version 0.11.1.git-4f92d31 Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 28 2012 14:56:41 with gcc 4.6.1 (GCC)
  configuration: --disable-ffprobe --disable-ffplay --enable-gpl
  libavutil      51. 70.100 / 51. 70.100
  libavcodec     54. 54.100 / 54. 54.100
  libavformat    54. 25.104 / 54. 25.104
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 13.101 /  3. 13.101
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[h264 @ 04490920] missing picture in access unit with size 1941
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 2377
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 2090
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 2305
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 3280
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 2963
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 2624
[h264 @ 04490920] no frame!
[h264 @ 04490920] illegal log2_max_frame_num 50
[h264 @ 04490920] missing picture in access unit with size 2937
[h264 @ 04490920] illegal log2_max_frame_num 50
    Last message repeated 1 times
[h264 @ 04490920] no frame!
[h264 @ 04490920] sps_id out of range
[h264 @ 04490920] missing picture in access unit with size 4221
[h264 @ 04490920] sps_id out of range
[h264 @ 04490920] no frame!
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] non-existing PPS 3 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 4270
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 3875
[h264 @ 04490920] no frame!
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] slice type too large (2) at 0 0
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] sps_id out of range
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 4394
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 4743
[h264 @ 04490920] Partitioned H.264 support is incomplete
[h264 @ 04490920] missing picture in access unit with size 5338
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 6106
[h264 @ 04490920] no frame!
[h264 @ 04490920] sps_id (32) out of range
[h264 @ 04490920] missing picture in access unit with size 5938
[h264 @ 04490920] sps_id (32) out of range
    Last message repeated 1 times
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 5345
[h264 @ 04490920] no frame!
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] non-existing PPS 1 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] too many reference frames
    Last message repeated 1 times
[h264 @ 04490920] non-existing PPS 0 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] non-existing PPS 0 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] sps_id out of range
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 5498
[h264 @ 04490920] Partitioned H.264 support is incomplete
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] non-existing PPS 10 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] no frame!
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] non-existing PPS 0 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] Partitioned H.264 support is incomplete
[h264 @ 04490920] sps_id out of range
[h264 @ 04490920] missing picture in access unit with size 5630
[h264 @ 04490920] sps_id out of range
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 5714
[h264 @ 04490920] non-existing PPS 2 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] no frame!
[h264 @ 04490920] sps_id out of range
    Last message repeated 1 times
[h264 @ 04490920] missing picture in access unit with size 5525
[h264 @ 04490920] sps_id out of range
    Last message repeated 1 times
[h264 @ 04490920] no frame!
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] non-existing PPS 0 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] non-existing PPS 0 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] no frame!
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] slice type too large (2) at 0 0
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] no frame!
[h264 @ 04490920] missing picture in access unit with size 5623
[h264 @ 04490920] no frame!
[h264 @ 04490920] FMO not supported
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] FMO not supported
[h264 @ 04490920] non-existing PPS 227 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] no frame!
[h264 @ 04490920] non-existing PPS referenced
[h264 @ 04490920] non-existing PPS 0 referenced
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] get_buffer() failed (-12 0 00000000)
[h264 @ 04490920] decode_slice_header error
[h264 @ 04490920] sps_id out of range
[h264 @ 04490920] concealing 297024 DC, 297024 AC, 297024 MV errors in P frame

Program received signal SIGSEGV, Segmentation fault.
0x00b553a8 in guess_dc (s=0x44efe80, dc=0x4be13c4, w=2496, h=476,
    stride=2497, is_luma=1) at libavcodec/error_resilience.c:197
197                 col [b_x + b_y*stride][1]= color;
(gdb) bt
#0  0x00b553a8 in guess_dc (s=0x44efe80, dc=0x4be13c4, w=2496, h=476,
    stride=2497, is_luma=1) at libavcodec/error_resilience.c:197
#1  0x008ed659 in ff_er_frame_end (s=0x44efe80)
    at libavcodec/error_resilience.c:1249
#2  0x0064818c in field_end (h=0x44efe80, in_setup=<optimized out>)
    at libavcodec/h264.c:2283
#3  0x00664f26 in decode_frame (avctx=0x4490920, data=0x22f5e0,
    data_size=0x22f7d8, avpkt=0x22f558) at libavcodec/h264.c:4139
#4  0x0055848b in avcodec_decode_video2 (avctx=0x4490920, picture=0x22f5e0,
    got_picture_ptr=0x22f7d8, avpkt=0x22f770) at libavcodec/utils.c:1512
#5  0x0047bbf2 in try_decode_frame (st=0x43adb40, avpkt=<optimized out>,
    options=<optimized out>) at libavformat/utils.c:2377
#6  0x004839c0 in avformat_find_stream_info (ic=0x43ad4e0, options=0x43a2740)
    at libavformat/utils.c:2749
#7  0x004056d7 in opt_input_file (optctx=0x22fd68, opt=0x43a2924 "i",
    filename=<optimized out>) at ffmpeg_opt.c:770
#8  0x00415467 in parse_option (optctx=0x22fd68, opt=<optimized out>,
    arg=0x43a2926 "h264.avi", options=0xb8caa0) at cmdutils.c:320
#9  0x004156d6 in parse_options (optctx=0x22fd68, argc=3,
    argv=<optimized out>, options=0xb8caa0,
    parse_arg_function=0x40616c <opt_output_file>) at cmdutils.c:353
#10 0x00b1a042 in main (argc=3, argv=<optimized out>) at ffmpeg.c:3126
(gdb)

Attachments (2)

h264.avi (1.2 MB ) - added by Carl Eugen Hoyos 12 years ago.
h264.avi.log (85.1 KB ) - added by Carl Eugen Hoyos 12 years ago.

Download all attachments as: .zip

Change History (19)

by Carl Eugen Hoyos, 12 years ago

Attachment: h264.avi added

in reply to:  description ; comment:1 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedavcodec
Keywords: h264 leak added
Version: unspecifiedgit-master

Replying to ami_stuff:

if I block mem request from ffmpeg I get crash

The crash was fixed in 16e52c86, the allocation is 4,779,403,502 bytes) and there are mem-leaks with rbsp_buffer.

comment:2 by Carl Eugen Hoyos, 12 years ago

Reproduced by developer: set
Status: newopen
Summary: h264: huge memory allocationh264: huge memory allocation and a memleak

No leak with -threads 1, memory usage rises to ~5G here with -threads 16

$ valgrind --leak-check=full ./ffmpeg_g -threads 2 -i h264.avi -f null -
==11415== Memcheck, a memory error detector
==11415== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==11415== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==11415== Command: ./ffmpeg_g -threads 2 -i h264.avi -f null -
==11415==
ffmpeg version N-46528-g5ff43ec Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov  8 2012 19:27:34 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52.  5.100 / 52.  5.100
  libavcodec     54. 71.100 / 54. 71.100
  libavformat    54. 36.100 / 54. 36.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 21.106 /  3. 21.106
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
[h264 @ 0x66ca000] missing picture in access unit with size 1941
[h264 @ 0x66ca000] no frame!
[h264 @ 0x66ca000] missing picture in access unit with size 2377
[h264 @ 0x66ca000] no frame!
[h264 @ 0x66ca000] missing picture in access unit with size 2090
[h264 @ 0x66ca000] no frame!
[h264 @ 0x66ca000] missing picture in access unit with size 2305
[h264 @ 0x66ca000] no frame!
[h264 @ 0x66ca000] missing picture in access unit with size 3280
[h264 @ 0x66ca000] no frame!
[h264 @ 0x66ca000] missing picture in access unit with size 2963
[h264 @ 0x66ca000] no frame!
[h264 @ 0x66ca000] missing picture in access unit with size 2624
[h264 @ 0x66ca000] no frame!
[h264 @ 0x66ca000] illegal log2_max_frame_num 50
[h264 @ 0x66ca000] missing picture in access unit with size 2937
[h264 @ 0x66ca000] illegal log2_max_frame_num 50

...

[h264 @ 0x66ca000] deblocking filter parameters 52 106 out of range
[h264 @ 0x66ca000] decode_slice_header error
[h264 @ 0x66ca000] concealing 297024 DC, 297024 AC, 297024 MV errors in P frame
Input #0, avi, from 'h264.avi':
  Duration: 00:00:12.64, start: 0.000000, bitrate: 788 kb/s
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 19968x3808, 12.33 fps, 23.98 tbr, 23.97 tbn, 47.94 tbc
[h264 @ 0x6970d20] sps_id (32) out of range
    Last message repeated 1 times
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf54.36.100
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 19968x3808, q=2-31, 200 kb/s, 90k tbn, 23.98 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> rawvideo)
Press [q] to stop, [?] for help
[h264 @ 0x6970d20] no frame!
[h264 @ 0x6c160e0] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 @ 0x6970d20] no frame!

...

[h264 @ 0x6c160e0] decode_slice_header error
[h264 @ 0x6c160e0] no frame!
Error while decoding stream #0:0: Operation not permitted
[h264 @ 0x6970d20] Width/height/bit depth/chroma idc changing with threads is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a
feature which has not been implemented.
[h264 @ 0x6970d20] decode_slice_header error
[h264 @ 0x6970d20] no frame!
Error while decoding stream #0:0: Operation not permitted
frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=   0.0kbits/s    ^M
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead -nan%
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
==11415==
==11415== HEAP SUMMARY:
==11415==     in use at exit: 7,813,977 bytes in 28 blocks
==11415==   total heap usage: 2,664 allocs, 2,636 frees, 2,495,641,669 bytes allocated
==11415==
==11415== 278,895 bytes in 1 blocks are definitely lost in loss record 1 of 2
==11415==    at 0x4C290FE: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11415==    by 0x4C291A7: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11415==    by 0xBA6CC1: av_mallocz (mem.c:97)
==11415==    by 0x98344B: av_fast_padded_malloc (utils.c:82)
==11415==    by 0x76F6FD: ff_h264_decode_nal (h264.c:240)
==11415==    by 0x774B1D: decode_nal_units (h264.c:3797)
==11415==    by 0x775949: ff_h264_decode_extradata (h264.c:1056)
==11415==    by 0x41DDFD: ff_h264_decode_init (h264.c:1104)
==11415==    by 0x8DFD12: ff_thread_init (pthread.c:860)
==11415==    by 0x987DEB: avcodec_open2 (utils.c:965)
==11415==    by 0x461433: transcode_init (ffmpeg.c:1882)
==11415==    by 0x450299: main (ffmpeg.c:2947)
==11415==
==11415== 7,535,082 bytes in 27 blocks are definitely lost in loss record 2 of 2
==11415==    at 0x4C290FE: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11415==    by 0x4C291A7: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11415==    by 0xBA6CC1: av_mallocz (mem.c:97)
==11415==    by 0x98344B: av_fast_padded_malloc (utils.c:82)
==11415==    by 0x76F6FD: ff_h264_decode_nal (h264.c:240)
==11415==    by 0x774B1D: decode_nal_units (h264.c:3797)
==11415==    by 0x775DA2: decode_frame (h264.c:4117)
==11415==    by 0x8DE245: frame_worker_thread (pthread.c:388)
==11415==    by 0x55C6E0D: start_thread (in /lib64/libpthread-2.15.so)
==11415==
==11415== LEAK SUMMARY:
==11415==    definitely lost: 7,813,977 bytes in 28 blocks
==11415==    indirectly lost: 0 bytes in 0 blocks
==11415==      possibly lost: 0 bytes in 0 blocks
==11415==    still reachable: 0 bytes in 0 blocks
==11415==         suppressed: 0 bytes in 0 blocks
==11415==
==11415== For counts of detected and suppressed errors, rerun with: -v
==11415== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)

by Carl Eugen Hoyos, 12 years ago

Attachment: h264.avi.log added

in reply to:  1 ; comment:3 by ami_stuff, 12 years ago

Replying to cehoyos:

Replying to ami_stuff:

if I block mem request from ffmpeg I get crash

The crash was fixed in 16e52c86

Could you try to reproduce the crash again with this "ulimit" tool? It still crashes for me with below command line when I block mem request (git head):

ffmpeg -cpuflags 0 -i h264.avi

If it doesn't crash for you I will compile new build soon to get a backtrace.

Last edited 12 years ago by ami_stuff (previous) (diff)

in reply to:  3 comment:4 by Carl Eugen Hoyos, 12 years ago

Replying to ami_stuff:

Replying to cehoyos:

Replying to ami_stuff:

if I block mem request from ffmpeg I get crash

The crash was fixed in 16e52c86

Could you try to reproduce the crash again with this "ulimit" tool? It still crashes for me

Which version crashes for you / could you provide a backtrace?

comment:5 by ami_stuff, 12 years ago

these two, but they are not mine, so no debug symbols

C:\>ffmpeg1
ffmpeg version N-46726-g2f74f8d Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 13 2012 19:29:51 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass -
-enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enab
le-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libo
pus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena
ble-zlib
  libavutil      52.  6.100 / 52.  6.100
  libavcodec     54. 71.100 / 54. 71.100
  libavformat    54. 36.100 / 54. 36.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.100 /  3. 23.100
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfi
le}...

Use -h to get full help or, even better, run 'man ffmpeg'
C:\>ffmpeg2
ffmpeg version N-46755-ge70144c Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 15 2012 02:38:20 with gcc 4.5.0 (GCC) 20100414 (Fedora MinGW 4.5.
0-1.fc14)
  configuration: --prefix=/var/www/users/research/ffmpeg/snapshots/build --arch=
x86 --target-os=mingw32 --cross-prefix=i686-pc-mingw32- --cc='ccache i686-pc-min
gw32-gcc' --enable-w32threads --enable-memalign-hack --enable-runtime-cpudetect
--enable-cross-compile --enable-static --disable-shared --extra-libs='-lws2_32 -
lwinmm -lpthread' --extra-cflags='--static -I/var/www/users/research/ffmpeg/snap
shots/build/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/s
napshots/build/lib' --enable-bzlib --enable-zlib --enable-gpl --enable-version3
--enable-nonfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-
libvorbis --enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      52.  6.100 / 52.  6.100
  libavcodec     54. 71.100 / 54. 71.100
  libavformat    54. 36.100 / 54. 36.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.100 /  3. 23.100
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfi
le}...

Use -h to get full help or, even better, run 'man ffmpeg'
(gdb) r -cpuflags 0 -i h264.avi
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: d:\mingw\msys\1.0\ffmpeg-head-b2b67fd\ffmpeg2.exe -cpuflags 0
-i h264.avi
[New Thread 5140.0x17a8]
ffmpeg version N-46755-ge70144c Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 15 2012 02:38:20 with gcc 4.5.0 (GCC) 20100414 (Fedora MinGW 4.5.
0-1.fc14)
  configuration: --prefix=/var/www/users/research/ffmpeg/snapshots/build --arch=
x86 --target-os=mingw32 --cross-prefix=i686-pc-mingw32- --cc='ccache i686-pc-min
gw32-gcc' --enable-w32threads --enable-memalign-hack --enable-runtime-cpudetect
--enable-cross-compile --enable-static --disable-shared --extra-libs='-lws2_32 -
lwinmm -lpthread' --extra-cflags='--static -I/var/www/users/research/ffmpeg/snap
shots/build/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/s
napshots/build/lib' --enable-bzlib --enable-zlib --enable-gpl --enable-version3
--enable-nonfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-
libvorbis --enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      52.  6.100 / 52.  6.100
  libavcodec     54. 71.100 / 54. 71.100
  libavformat    54. 36.100 / 54. 36.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.100 /  3. 23.100
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
[h264 @ 0x1edce80] missing picture in access unit with size 1941
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 2377
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 2090
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 2305
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 3280
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 2963
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 2624
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] illegal log2_max_frame_num 50
[h264 @ 0x1edce80] missing picture in access unit with size 2937
[h264 @ 0x1edce80] illegal log2_max_frame_num 50
    Last message repeated 1 times
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] sps_id out of range
[h264 @ 0x1edce80] missing picture in access unit with size 4221
[h264 @ 0x1edce80] sps_id out of range
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 3 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 4270
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 3875
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] slice type too large (2) at 0 0
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] sps_id out of range
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 4394
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 4743
[h264 @ 0x1edce80] Partitioned H.264 support is incomplete
[h264 @ 0x1edce80] missing picture in access unit with size 5338
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 6106
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] sps_id (32) out of range
[h264 @ 0x1edce80] missing picture in access unit with size 5938
[h264 @ 0x1edce80] sps_id (32) out of range
    Last message repeated 1 times
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 5345
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 1 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] too many reference frames
    Last message repeated 1 times
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] sps_id out of range
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 5498
[h264 @ 0x1edce80] Partitioned H.264 support is incomplete
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 10 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] Partitioned H.264 support is incomplete
[h264 @ 0x1edce80] sps_id out of range
[h264 @ 0x1edce80] missing picture in access unit with size 5630
[h264 @ 0x1edce80] sps_id out of range
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 5714
[h264 @ 0x1edce80] non-existing PPS 2 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] sps_id out of range
    Last message repeated 1 times
[h264 @ 0x1edce80] missing picture in access unit with size 5525
[h264 @ 0x1edce80] sps_id out of range
    Last message repeated 1 times
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] slice type too large (2) at 0 0
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] missing picture in access unit with size 5623
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] FMO not supported
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] FMO not supported
[h264 @ 0x1edce80] non-existing PPS 227 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] Cannot allocate memory.
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] sps_id out of range
[h264 @ 0x1edce80] concealing 297024 DC, 297024 AC, 297024 MV errors in P frame
[h264 @ 0x1edce80] guess_dc() is out of memory
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] illegal POC type 7
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] illegal POC type 7
    Last message repeated 1 times
[h264 @ 0x1edce80] slice type too large (3) at 0 0
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] non-existing PPS 3 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] non-existing PPS 6 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 13 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] non-existing PPS 10 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] Partitioned H.264 support is incomplete
[h264 @ 0x1edce80] missing picture in access unit with size 5668
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] sps_id (32) out of range
[h264 @ 0x1edce80] missing picture in access unit with size 5753
[h264 @ 0x1edce80] sps_id (32) out of range
    Last message repeated 1 times
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 5903
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 6 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] non-existing PPS referenced
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] non-existing PPS 0 referenced
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] missing picture in access unit with size 5680
[h264 @ 0x1edce80] no frame!
[h264 @ 0x1edce80] Missing reference picture, default is 2
    Last message repeated 1 times
[h264 @ 0x1edce80] deblocking filter parameters 52 106 out of range
[h264 @ 0x1edce80] decode_slice_header error
[h264 @ 0x1edce80] Warning MVs not available
[h264 @ 0x1edce80] concealing 297024 DC, 297024 AC, 297024 MV errors in P frame

Program received signal SIGSEGV, Segmentation fault.
0x0090a710 in ?? ()

comment:6 by Carl Eugen Hoyos, 12 years ago

I get the following with "ulimit -Sv 1200000", not reproducible with -threads 1:

$ valgrind ffmpeg_g -i h264.avi -f null -

[...]

Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
==26146== Invalid free() / delete / delete[] / realloc()
==26146==    at 0x4C29D4E: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26146==    by 0xBAB4EB: av_freep (mem.c:190)
==26146==    by 0x8962CA: ff_MPV_common_end (mpegvideo.c:471)
==26146==    by 0x41EA4D: h264_decode_end (h264.c:4176)
==26146==    by 0x8E2754: frame_thread_free (pthread.c:771)
==26146==    by 0x4348B1: avcodec_close (utils.c:1963)
==26146==    by 0x453939: main (ffmpeg.c:3025)
==26146==  Address 0x3ade9080 is not stack'd, malloc'd or (recently) free'd
==26146==
==26146== Invalid free() / delete / delete[] / realloc()
==26146==    at 0x4C29D4E: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26146==    by 0xBAB4EB: av_freep (mem.c:190)
==26146==    by 0x8962D6: ff_MPV_common_end (mpegvideo.c:472)
==26146==    by 0x41EA4D: h264_decode_end (h264.c:4176)
==26146==    by 0x8E2754: frame_thread_free (pthread.c:771)
==26146==    by 0x4348B1: avcodec_close (utils.c:1963)
==26146==    by 0x453939: main (ffmpeg.c:3025)
==26146==  Address 0x3b1e9080 is 0 bytes inside a block of size 297,262 free'd
==26146==    at 0x4C29D4E: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26146==    by 0xBAB4EB: av_freep (mem.c:190)
==26146==    by 0x8962D6: ff_MPV_common_end (mpegvideo.c:472)
==26146==    by 0x4282F6: ff_MPV_common_init (mpegvideo.c:914)
==26146==    by 0x896C13: ff_mpeg_update_thread_context (mpegvideo.c:551)
==26146==    by 0x772A99: decode_update_thread_context (h264.c:1179)
==26146==    by 0x8E2D1C: ff_thread_decode_frame (pthread.c:458)
==26146==    by 0x98ABD3: avcodec_decode_video2 (utils.c:1663)
==26146==    by 0x45FCB4: decode_video (ffmpeg.c:1563)
==26146==    by 0x453EEC: main (ffmpeg.c:1764)
==26146==
==26146== Invalid free() / delete / delete[] / realloc()
==26146==    at 0x4C29D4E: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26146==    by 0xBAB4EB: av_freep (mem.c:190)
==26146==    by 0x896332: ff_MPV_common_end (mpegvideo.c:481)
==26146==    by 0x41EA4D: h264_decode_end (h264.c:4176)
==26146==    by 0x8E2754: frame_thread_free (pthread.c:771)
==26146==    by 0x4348B1: avcodec_close (utils.c:1963)
==26146==    by 0x453939: main (ffmpeg.c:3025)
==26146==  Address 0x22e1c8e0 is 0 bytes inside a block of size 2,520 free'd
==26146==    at 0x4C29D4E: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26146==    by 0xBAB4EB: av_freep (mem.c:190)
==26146==    by 0x896332: ff_MPV_common_end (mpegvideo.c:481)
==26146==    by 0x4282F6: ff_MPV_common_init (mpegvideo.c:914)
==26146==    by 0x896C13: ff_mpeg_update_thread_context (mpegvideo.c:551)
==26146==    by 0x772A99: decode_update_thread_context (h264.c:1179)
==26146==    by 0x8E2D1C: ff_thread_decode_frame (pthread.c:458)
==26146==    by 0x98ABD3: avcodec_decode_video2 (utils.c:1663)
==26146==    by 0x45FCB4: decode_video (ffmpeg.c:1563)
==26146==    by 0x453EEC: main (ffmpeg.c:1764)
==26146==
==26146==
==26146== HEAP SUMMARY:
==26146==     in use at exit: 7,535,176 bytes in 27 blocks
==26146==   total heap usage: 4,035 allocs, 5,053 frees, 2,003,924,921 bytes allocated
==26146==
==26146== LEAK SUMMARY:
==26146==    definitely lost: 7,256,557 bytes in 26 blocks
==26146==    indirectly lost: 0 bytes in 0 blocks
==26146==      possibly lost: 278,619 bytes in 1 blocks
==26146==    still reachable: 0 bytes in 0 blocks
==26146==         suppressed: 0 bytes in 0 blocks
==26146== Rerun with --leak-check=full to see details of leaked memory
==26146==
==26146== For counts of detected and suppressed errors, rerun with: -v
==26146== ERROR SUMMARY: 1311 errors from 13 contexts (suppressed: 2 from 2)

comment:7 by Carl Eugen Hoyos, 12 years ago

Priority: normalimportant
Summary: h264: huge memory allocation and a memleakh264: huge memory allocation and a memleak, possible race condition

comment:8 by Carl Eugen Hoyos, 12 years ago

Summary: h264: huge memory allocation and a memleak, possible race conditionh264: huge memory allocation and a memleak

I cannot reproduce the race condition anymore, valgrind still reports a 6M memleak and >3.5G memory allocation.

comment:9 by Carl Eugen Hoyos, 12 years ago

No memory leak with -threads 1. (Memory allocation varies, the following run was stopped early.)

$ valgrind --leak-check=full ffmpeg_g -threads 2 -i h264.avi -f null -
==20435== Memcheck, a memory error detector
==20435== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==20435== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==20435== Command: ffmpeg_g -i h264.avi -f null -
==20435==
ffmpeg version N-48119-gf9d8658 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 23 2012 11:31:11 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack --disable-yasm --disable-asm --disable-optimizations
  libavutil      52. 12.100 / 52. 12.100
  libavcodec     54. 81.100 / 54. 81.100
  libavformat    54. 49.102 / 54. 49.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 29.101 /  3. 29.101
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100

[...]

==20435== HEAP SUMMARY:
==20435==     in use at exit: 7,813,977 bytes in 28 blocks
==20435==   total heap usage: 2,207 allocs, 2,179 frees, 1,948,151,926 bytes allocated
==20435==
==20435== 278,895 bytes in 1 blocks are definitely lost in loss record 1 of 2
==20435==    at 0x4C290FE: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20435==    by 0x4C291A7: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20435==    by 0xC9E701: av_malloc (mem.c:92)
==20435==    by 0xC9E861: av_mallocz (mem.c:198)
==20435==    by 0xA3E900: ff_fast_malloc (utils.c:82)
==20435==    by 0xA3E9C3: av_fast_padded_malloc (utils.c:102)
==20435==    by 0x71B5F3: ff_h264_decode_nal (h264.c:240)
==20435==    by 0x777EDC: decode_nal_units (h264.c:3983)
==20435==    by 0x71D71B: ff_h264_decode_extradata (h264.c:1056)
==20435==    by 0x71D94E: ff_h264_decode_init (h264.c:1108)
==20435==    by 0x986FB4: frame_thread_init (pthread.c:860)
==20435==    by 0x98794F: ff_thread_init (pthread.c:1090)
==20435==
==20435== 7,535,082 bytes in 27 blocks are definitely lost in loss record 2 of 2
==20435==    at 0x4C290FE: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20435==    by 0x4C291A7: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20435==    by 0xC9E701: av_malloc (mem.c:92)
==20435==    by 0xC9E861: av_mallocz (mem.c:198)
==20435==    by 0xA3E900: ff_fast_malloc (utils.c:82)
==20435==    by 0xA3E9C3: av_fast_padded_malloc (utils.c:102)
==20435==    by 0x71B5F3: ff_h264_decode_nal (h264.c:240)
==20435==    by 0x777EDC: decode_nal_units (h264.c:3983)
==20435==    by 0x779067: decode_frame (h264.c:4332)
==20435==    by 0x985A9C: frame_worker_thread (pthread.c:388)
==20435==    by 0x55C6E0D: start_thread (in /lib64/libpthread-2.15.so)
==20435==
==20435== LEAK SUMMARY:
==20435==    definitely lost: 7,813,977 bytes in 28 blocks
==20435==    indirectly lost: 0 bytes in 0 blocks
==20435==      possibly lost: 0 bytes in 0 blocks
==20435==    still reachable: 0 bytes in 0 blocks
==20435==         suppressed: 0 bytes in 0 blocks

comment:10 by Michael Niedermayer, 12 years ago

huge memory allocations can be prevented by limiting through -max_alloc X.
While its possible in specific cases to more intelligently prevent huge allocations, this is not true in general, one can always encounter a file that stores a 8000x8000 yuv 4:4:4 16bit video that needs 16 frame buffers.

comment:11 by Carl Eugen Hoyos, 12 years ago

Priority: importantnormal

comment:12 by Carl Eugen Hoyos, 12 years ago

Several identical allocations (the biggest) happen in av_image_alloc() for images with a resolution of 20000x4000, this could happen in valid streams, more such allocations happen if threads > 1.
The memleak with threads > 1 is still reproducible.

comment:13 by Carl Eugen Hoyos, 12 years ago

Summary: h264: huge memory allocation and a memleakh264: memleak with threads > 1

comment:14 by ami_stuff, 11 years ago

just tested this and got crash with:

ffmpeg -max_alloc 199900 -i h264.avi

could you try to reproduce?

Last edited 11 years ago by ami_stuff (previous) (diff)

in reply to:  14 comment:15 by Carl Eugen Hoyos, 11 years ago

Replying to ami_stuff:

just tested this and got crash with:

ffmpeg -max_alloc 199900 -i h264.avi

Should be fixed, thank you for the report!

comment:16 by Michael Niedermayer, 11 years ago

This ticket talks about many different issues, memleaks, several crashes. If some issues remain, please open seperate ticket(s) for them and ill look at them. As is, with just this ticket i dont know where to start or what if any issues remains.

comment:17 by Carl Eugen Hoyos, 11 years ago

Resolution: fixed
Status: openclosed

Fixed by Michael in 626739e.

Note: See TracTickets for help on using tickets.