Opened 3 years ago

Last modified 3 years ago

#4807 open defect

valgrind report uninitialized memory error muxing HEVC file

Reported by: michel.promonet Owned by:
Priority: minor Component: avformat
Version: git-master Keywords: hevc
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description (last modified by cehoyos)

Summary of the bug:
Muxing an HEVC elementary stream file to MP4 under valgrind report the following errors:

==13039== Memcheck, a memory error detector
==13039== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==13039== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==13039== Command: ../../../svsExamples/ffmpeg -i video-H265-1 -c:v copy toto.mp4 -y
==13039==
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/data/home/mpr/ip7000/.build/x86_64-linux-gnu/libroot --enable-static --disable-shared --enable-shared --disable-static --disable-asm --extra-ldflags='-Wl,-rpath,/data/home/mpr/ip7000/.build/x86_64-linux-gnu/libroot/lib -Wl,-rpath,'\''\$\$ORIGIN/../lib'\'' -ldl' --enable-debug --disable-optimizations --disable-stripping --disable-doc --disable-devices --disable-postproc --disable-filters --disable-network --disable-bsfs --disable-protocols --enable-protocol=file --disable-filters --enable-pic --disable-iconv --disable-zlib --disable-bzlib --disable-xlib
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
[hevc @ 0x7bba620] Unknown HEVC profile: 0
    Last message repeated 7 times
Input #0, hevc, from 'video-H265-1':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: hevc, yuv420p(tv), 1280x720, 25 fps, 25 tbr, 1200k tbn, 25 tbc
[mp4 @ 0x7f92410] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mp4, to 'toto.mp4':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: hevc ([35][0][0][0] / 0x0023), yuv420p, 1280x720, q=2-31, 25 fps, 25 tbr, 1200k tbn, 1200k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x7f92410] pts has no value
    Last message repeated 35 times
==13039==    at 0x704189D: VALGRIND_PRINTF_BACKTRACE (valgrind.h:5631)
==13039==    by 0x70423C1: av_log_default_callback (log.c:346)
==13039==    by 0x7042558: av_vlog (log.c:374)
==13039==    by 0x7042518: av_log (log.c:366)
==13039==    by 0x41ED8A: term_exit (ffmpeg.c:309)
==13039==    by 0x42EC5A: transcode (ffmpeg.c:3958)
==13039==    by 0x42F158: main (ffmpeg.c:4111)
==13039== Conditional jump or move depends on uninitialised value(s)
==13039==    at 0x52DA55C: get_ue_golomb_long (intmath.h:67)
==13039==    by 0x52DAF5E: parse_rps (hevc.c:471)
==13039==    by 0x52DB30F: hvcc_parse_sps (hevc.c:562)
==13039==    by 0x52DBA0E: hvcc_add_nal_unit (hevc.c:779)
==13039==    by 0x52DC85D: ff_isom_write_hvcc (hevc.c:1131)
==13039==    by 0x531F0B6: mov_write_hvcc_tag (movenc.c:1033)
==13039==    by 0x5321AA8: mov_write_video_tag (movenc.c:1711)
==13039==    by 0x532256E: mov_write_stsd_tag (movenc.c:1850)
==13039==    by 0x5322CCB: mov_write_stbl_tag (movenc.c:1965)
==13039==    by 0x5323DF5: mov_write_minf_tag (movenc.c:2208)
==13039==    by 0x5324180: mov_write_mdia_tag (movenc.c:2262)
==13039==    by 0x5325A6B: mov_write_trak_tag (movenc.c:2626)
==13039==
==13039== Invalid read of size 4
==13039==    at 0x52DA006: get_bits (get_bits.h:265)
==13039==    by 0x52DA22F: get_bits_long (get_bits.h:349)
==13039==    by 0x52DA2F1: show_bits_long (get_bits.h:389)
==13039==    by 0x52DA542: get_ue_golomb_long (golomb.h:89)
==13039==    by 0x52DB42E: hvcc_parse_pps (hevc.c:590)
==13039==    by 0x52DBA2E: hvcc_add_nal_unit (hevc.c:781)
==13039==    by 0x52DC85D: ff_isom_write_hvcc (hevc.c:1131)
==13039==    by 0x531F0B6: mov_write_hvcc_tag (movenc.c:1033)
==13039==    by 0x5321AA8: mov_write_video_tag (movenc.c:1711)
==13039==    by 0x532256E: mov_write_stsd_tag (movenc.c:1850)
==13039==    by 0x5322CCB: mov_write_stbl_tag (movenc.c:1965)
==13039==    by 0x5323DF5: mov_write_minf_tag (movenc.c:2208)
==13039==  Address 0x8004bd4 is 4 bytes inside a block of size 7 alloc'd
==13039==    at 0x4C2D110: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13039==    by 0x4C2D227: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13039==    by 0x7044B44: av_malloc (mem.c:95)
==13039==    by 0x52DB546: nal_unit_extract_rbsp (hevc.c:647)
==13039==    by 0x52DB937: hvcc_add_nal_unit (hevc.c:749)
==13039==    by 0x52DC85D: ff_isom_write_hvcc (hevc.c:1131)
==13039==    by 0x531F0B6: mov_write_hvcc_tag (movenc.c:1033)
==13039==    by 0x5321AA8: mov_write_video_tag (movenc.c:1711)
==13039==    by 0x532256E: mov_write_stsd_tag (movenc.c:1850)
==13039==    by 0x5322CCB: mov_write_stbl_tag (movenc.c:1965)
==13039==    by 0x5323DF5: mov_write_minf_tag (movenc.c:2208)
==13039==    by 0x5324180: mov_write_mdia_tag (movenc.c:2262)
==13039==
==13039== Invalid read of size 4
==13039==    at 0x52DA006: get_bits (get_bits.h:265)
==13039==    by 0x52DA20E: get_bits_long (get_bits.h:348)
==13039==    by 0x52DA2F1: show_bits_long (get_bits.h:389)
==13039==    by 0x52DA542: get_ue_golomb_long (golomb.h:89)
==13039==    by 0x52DA5E0: get_se_golomb_long (golomb.h:217)
==13039==    by 0x52DB4A8: hvcc_parse_pps (hevc.c:615)
==13039==    by 0x52DBA2E: hvcc_add_nal_unit (hevc.c:781)
==13039==    by 0x52DC85D: ff_isom_write_hvcc (hevc.c:1131)
==13039==    by 0x531F0B6: mov_write_hvcc_tag (movenc.c:1033)
==13039==    by 0x5321AA8: mov_write_video_tag (movenc.c:1711)
==13039==    by 0x532256E: mov_write_stsd_tag (movenc.c:1850)
==13039==    by 0x5322CCB: mov_write_stbl_tag (movenc.c:1965)
==13039==  Address 0x8004bd4 is 4 bytes inside a block of size 7 alloc'd
==13039==    at 0x4C2D110: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13039==    by 0x4C2D227: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13039==    by 0x7044B44: av_malloc (mem.c:95)
==13039==    by 0x52DB546: nal_unit_extract_rbsp (hevc.c:647)
==13039==    by 0x52DB937: hvcc_add_nal_unit (hevc.c:749)
==13039==    by 0x52DC85D: ff_isom_write_hvcc (hevc.c:1131)
==13039==    by 0x531F0B6: mov_write_hvcc_tag (movenc.c:1033)
==13039==    by 0x5321AA8: mov_write_video_tag (movenc.c:1711)
==13039==    by 0x532256E: mov_write_stsd_tag (movenc.c:1850)
==13039==    by 0x5322CCB: mov_write_stbl_tag (movenc.c:1965)
==13039==    by 0x5323DF5: mov_write_minf_tag (movenc.c:2208)
==13039==    by 0x5324180: mov_write_mdia_tag (movenc.c:2262)
==13039==
==13039== Invalid read of size 4
==13039==    at 0x52DA006: get_bits (get_bits.h:265)
==13039==    by 0x52DA1FB: get_bits_long (get_bits.h:342)
==13039==    by 0x52DA5C3: get_ue_golomb_long (golomb.h:93)
==13039==    by 0x52DA5E0: get_se_golomb_long (golomb.h:217)
==13039==    by 0x52DB4A8: hvcc_parse_pps (hevc.c:615)
==13039==    by 0x52DBA2E: hvcc_add_nal_unit (hevc.c:781)
==13039==    by 0x52DC85D: ff_isom_write_hvcc (hevc.c:1131)
==13039==    by 0x531F0B6: mov_write_hvcc_tag (movenc.c:1033)
==13039==    by 0x5321AA8: mov_write_video_tag (movenc.c:1711)
==13039==    by 0x532256E: mov_write_stsd_tag (movenc.c:1850)
==13039==    by 0x5322CCB: mov_write_stbl_tag (movenc.c:1965)
==13039==    by 0x5323DF5: mov_write_minf_tag (movenc.c:2208)
==13039==  Address 0x8004bd4 is 4 bytes inside a block of size 7 alloc'd
==13039==    at 0x4C2D110: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13039==    by 0x4C2D227: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13039==    by 0x7044B44: av_malloc (mem.c:95)
==13039==    by 0x52DB546: nal_unit_extract_rbsp (hevc.c:647)
==13039==    by 0x52DB937: hvcc_add_nal_unit (hevc.c:749)
==13039==    by 0x52DC85D: ff_isom_write_hvcc (hevc.c:1131)
==13039==    by 0x531F0B6: mov_write_hvcc_tag (movenc.c:1033)
==13039==    by 0x5321AA8: mov_write_video_tag (movenc.c:1711)
==13039==    by 0x532256E: mov_write_stsd_tag (movenc.c:1850)
==13039==    by 0x5322CCB: mov_write_stbl_tag (movenc.c:1965)
==13039==    by 0x5323DF5: mov_write_minf_tag (movenc.c:2208)
==13039==    by 0x5324180: mov_write_mdia_tag (movenc.c:2262)
==13039==
frame=   36 fps=0.0 q=-1.0 Lsize=     273kB time=00:00:01.36 bitrate=1646.3kbits/s
video:272kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.410793%
==13039==    at 0x704189D: VALGRIND_PRINTF_BACKTRACE (valgrind.h:5631)
==13039==    by 0x70423C1: av_log_default_callback (log.c:346)
==13039==    by 0x7042558: av_vlog (log.c:374)
==13039==    by 0x7042518: av_log (log.c:366)
==13039==    by 0x41ED8A: term_exit (ffmpeg.c:309)
==13039==    by 0x41F635: ffmpeg_cleanup (ffmpeg.c:543)
==13039==    by 0x40791A: exit_program (cmdutils.c:126)
==13039==    by 0x42F230: main (in /data/home/mpr/ip7000/.build/x86_64-linux-gnu/libroot/bin/ffmpeg)
==13039==
==13039== HEAP SUMMARY:
==13039==     in use at exit: 40 bytes in 1 blocks
==13039==   total heap usage: 1,648 allocs, 1,647 frees, 4,590,774 bytes allocated
==13039==
==13039== LEAK SUMMARY:
==13039==    definitely lost: 0 bytes in 0 blocks
==13039==    indirectly lost: 0 bytes in 0 blocks
==13039==      possibly lost: 0 bytes in 0 blocks
==13039==    still reachable: 40 bytes in 1 blocks
==13039==         suppressed: 0 bytes in 0 blocks
==13039== Rerun with --leak-check=full to see details of leaked memory
==13039==
==13039== For counts of detected and suppressed errors, rerun with: -v
==13039== Use --track-origins=yes to see where uninitialised values come from
==13039== ERROR SUMMARY: 18 errors from 4 contexts (suppressed: 0 from 0)

How to reproduce:

% ffmpeg -i video-H265-1 -c:v copy toto.mp4 
ffmpeg 2.7.2
built on Ubuntu 14.04

Attachments (1)

video-H265-1 (272.2 KB) - added by michel.promonet 3 years ago.
HEVC elementary stream file referenced in the ticket

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by michel.promonet

HEVC elementary stream file referenced in the ticket

comment:1 Changed 3 years ago by michel.promonet

  • Version changed from unspecified to 2.7

comment:2 Changed 3 years ago by cehoyos

Is this issue not reproducible with current FFmpeg git head?
Please test and report back.

comment:3 follow-up: Changed 3 years ago by michel.promonet

I just checked with git revision a16251a6d0401c772bd985f4c611caf97ca5e537
There is less errors, but still somes :

ffmpeg version N-74650-ga16251a Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --enable-static --disable-shared --disable-asm --enable-debug --disable-optimizations --disable-stripping --disable-doc --disable-devices --disable-postproc --disable-filters --disable-network --disable-bsfs --disable-protocols --enable-protocol=file --disable-filters --enable-pic --disable-iconv --disable-zlib --disable-bzlib --disable-xlib
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 58.100 / 56. 58.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 37.100 /  5. 37.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
[hevc @ 0x5732b50] Unknown HEVC profile: 0
    Last message repeated 11 times
Input #0, hevc, from 'video-H265-1':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: hevc, yuv420p(tv), 1280x720, 25 fps, 25 tbr, 1200k tbn, 25 tbc
[mp4 @ 0x5b15bf0] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mp4, to 'toto.mp4':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: hevc ([35][0][0][0] / 0x0023), yuv420p, 1280x720, q=2-31, 25 fps, 25 tbr, 1200k tbn, 1200k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x5b15bf0] pts has no value
    Last message repeated 35 times
==26832==    at 0x1095080: VALGRIND_PRINTF_BACKTRACE (valgrind.h:5631)
==26832==    by 0x1095BA4: av_log_default_callback (log.c:346)
==26832==    by 0x1095D3B: av_vlog (log.c:374)
==26832==    by 0x1095CFB: av_log (log.c:366)
==26832==    by 0x41B145: term_exit (ffmpeg.c:313)
==26832==    by 0x42B036: transcode (ffmpeg.c:4006)
==26832==    by 0x42B549: main (ffmpeg.c:4160)
==26832== Conditional jump or move depends on uninitialised value(s)
==26832==    at 0x59E4F2: get_ue_golomb_long (intmath.h:62)
==26832==    by 0x59EEF4: parse_rps (hevc.c:471)
==26832==    by 0x59F2A5: hvcc_parse_sps (hevc.c:562)
==26832==    by 0x59F9CC: hvcc_add_nal_unit (hevc.c:783)
==26832==    by 0x5A081B: ff_isom_write_hvcc (hevc.c:1135)
==26832==    by 0x4D81DB: mov_write_hvcc_tag (movenc.c:1034)
==26832==    by 0x4DABCD: mov_write_video_tag (movenc.c:1712)
==26832==    by 0x4DB693: mov_write_stsd_tag (movenc.c:1851)
==26832==    by 0x4DBDF0: mov_write_stbl_tag (movenc.c:1966)
==26832==    by 0x4DCF1A: mov_write_minf_tag (movenc.c:2209)
==26832==    by 0x4DD2A5: mov_write_mdia_tag (movenc.c:2263)
==26832==    by 0x4DEB76: mov_write_trak_tag (movenc.c:2627)
==26832==
frame=   36 fps=0.0 q=-1.0 Lsize=     273kB time=00:00:01.36 bitrate=1646.3kbits/s
video:272kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.410793%
==26832==    at 0x1095080: VALGRIND_PRINTF_BACKTRACE (valgrind.h:5631)
==26832==    by 0x1095BA4: av_log_default_callback (log.c:346)
==26832==    by 0x1095D3B: av_vlog (log.c:374)
==26832==    by 0x1095CFB: av_log (log.c:366)
==26832==    by 0x41B145: term_exit (ffmpeg.c:313)
==26832==    by 0x41BA10: ffmpeg_cleanup (ffmpeg.c:583)
==26832==    by 0x4035C6: exit_program (cmdutils.c:119)
==26832==    by 0x42B62B: main (in /data/home/mpr/ffmpeg/ffmpeg_g)
==26832==
==26832== HEAP SUMMARY:
==26832==     in use at exit: 40 bytes in 1 blocks
==26832==   total heap usage: 1,588 allocs, 1,587 frees, 4,486,574 bytes allocated
==26832==
==26832== LEAK SUMMARY:
==26832==    definitely lost: 0 bytes in 0 blocks
==26832==    indirectly lost: 0 bytes in 0 blocks
==26832==      possibly lost: 0 bytes in 0 blocks
==26832==    still reachable: 40 bytes in 1 blocks
==26832==         suppressed: 0 bytes in 0 blocks
==26832== Rerun with --leak-check=full to see details of leaked memory
==26832==
==26832== For counts of detected and suppressed errors, rerun with: -v
==26832== Use --track-origins=yes to see where uninitialised values come from
==26832== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 0 from 0)
Last edited 3 years ago by cehoyos (previous) (diff)

comment:4 in reply to: ↑ 3 Changed 3 years ago by Timothy_Gu

Replying to michel.promonet:

Next time could you please surround {{{ and }}} around code blocks? It'd be much easier to read the output.

comment:5 Changed 3 years ago by cehoyos

  • Component changed from undetermined to avformat
  • Description modified (diff)
  • Keywords valgrind h265 muxing removed
  • Priority changed from normal to minor
  • Status changed from new to open
  • Version changed from 2.7 to git-master

comment:6 Changed 3 years ago by cehoyos

  • Reproduced by developer set
Note: See TracTickets for help on using tickets.