[FFmpeg-devel] [PATCH 03/10] avformat/utils: use av_packet_alloc() to allocate packets

Michael Niedermayer michael at niedermayer.cc
Thu Feb 4 00:23:15 EET 2021


On Mon, Feb 01, 2021 at 07:44:14PM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> av_get_packet() and av_read_frame() were allowed to be called with
> uninitialized packets in stack, so to keep supporting that we need to leave the
> calls to av_init_packet() in place during the deprecation period.
> 
>  libavformat/internal.h |   1 +
>  libavformat/options.c  |  13 +++--
>  libavformat/utils.c    | 105 +++++++++++++++++++++++------------------
>  3 files changed, 68 insertions(+), 51 deletions(-)

valgrind dislikes this

will send you the file by private mail

[avi @ 0x169f9280] Something went wrong during header parsing, tag [0][0][0][0] has size 2147483648, I will ignore it and try to continue anyway.
[avi @ 0x169f9280] non-interleaved AVI
[avi @ 0x169f9280] nothing to probe for stream 2
[avi @ 0x169f9280] probed stream 2 failed
[avi @ 0x169f9280] probed stream 6 failed
[avi @ 0x169f9280] nothing to probe for stream 7
[avi @ 0x169f9280] probed stream 7 failed
[avi @ 0x169f9280] nothing to probe for stream 8
[avi @ 0x169f9280] probed stream 8 failed
[avi @ 0x169f9280] nothing to probe for stream 9
[avi @ 0x169f9280] probed stream 9 failed
[avi @ 0x169f9280] Could not find codec parameters for stream 0 (Video: mpeg4 (XVID / 0x44495658), none, 640x480): unspecified pixel format
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[avi @ 0x169f9280] Could not find codec parameters for stream 2 (Subtitle: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[avi @ 0x169f9280] Could not find codec parameters for stream 4 (Unknown: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[avi @ 0x169f9280] Could not find codec parameters for stream 6 (Subtitle: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[avi @ 0x169f9280] Could not find codec parameters for stream 7 (Subtitle: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[avi @ 0x169f9280] Could not find codec parameters for stream 8 (Subtitle: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[avi @ 0x169f9280] Could not find codec parameters for stream 9 (Subtitle: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, avi, from 'mewmew_ssa.avi.asan.1c.3781':
  Duration: 00:00:58.22, start: 0.000000, bitrate: 1087 kb/s
  Stream #0:0: Video: mpeg4 (XVID / 0x44495658), none, 640x480, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
  Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 64 kb/s
    Metadata:
      title           : test
  Stream #0:2: Subtitle: none
    Metadata:
      title           : Credits
  Stream #0:3: Subtitle: ass
  Stream #0:4: Unknown: none
    Metadata:
      title           : English
  Stream #0:5: Subtitle: ass
    Metadata:
      title           : Finnish
  Stream #0:6: Subtitle: none
    Metadata:
      title           : French
  Stream #0:7: Subtitle: none
    Metadata:
      title           : Hebrew
  Stream #0:8: Subtitle: none
    Metadata:
      title           : Hungarian
  Stream #0:9: Subtitle: none
    Metadata:
      title           : Italian
At least one output file must be specified
==12602==    at 0x121EC6E: VALGRIND_PRINTF_BACKTRACE (valgrind.h:6303)
==12602==    by 0x121F82C: av_log_default_callback (log.c:397)
==12602==    by 0x121FAD3: av_vlog (log.c:432)
==12602==    by 0x121F932: av_log (log.c:411)
==12602==    by 0x25B892: main (ffmpeg.c:4971)
==12602== Invalid read of size 8
==12602==    at 0x1208302: buffer_replace (buffer.c:111)
==12602==    by 0x12083D7: av_buffer_unref (buffer.c:130)
==12602==    by 0x794E97: av_packet_unref (avpacket.c:609)
==12602==    by 0x795651: avpriv_packet_list_free (avpacket.c:789)
==12602==    by 0x7026A2: flush_packet_queue (utils.c:1833)
==12602==    by 0x70C29B: avformat_close_input (utils.c:4484)
==12602==    by 0x24A207: ffmpeg_cleanup (ffmpeg.c:626)
==12602==    by 0x241A25: exit_program (cmdutils.c:136)
==12602==    by 0x25B89C: main (ffmpeg.c:4972)
==12602==  Address 0x16a46dc0 is 0 bytes inside a block of size 24 free'd
==12602==    at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12602==    by 0x122297A: av_free (mem.c:224)
==12602==    by 0x12229C2: av_freep (mem.c:234)
==12602==    by 0x120834D: buffer_replace (buffer.c:117)
==12602==    by 0x12083D7: av_buffer_unref (buffer.c:130)
==12602==    by 0x794E97: av_packet_unref (avpacket.c:609)
==12602==    by 0x6FDF58: ff_read_packet (utils.c:808)
==12602==    by 0x569798: get_subtitle_pkt (avidec.c:1183)
==12602==    by 0x56A3E4: avi_read_packet (avidec.c:1452)
==12602==    by 0x6FE05A: ff_read_packet (utils.c:827)
==12602==    by 0x7011F0: read_frame_internal (utils.c:1529)
==12602==    by 0x709592: avformat_find_stream_info (utils.c:3794)
==12602==    by 0x22D4C9: open_input_file (ffmpeg_opt.c:1195)
==12602==    by 0x23BC31: open_files (ffmpeg_opt.c:3318)
==12602==    by 0x23BDE5: ffmpeg_parse_options (ffmpeg_opt.c:3358)
==12602==    by 0x25B809: main (ffmpeg.c:4959)
==12602==  Block was alloc'd at
==12602==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12602==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12602==    by 0x12225DC: av_malloc (mem.c:86)
==12602==    by 0x12229F1: av_mallocz (mem.c:239)
==12602==    by 0x1208296: av_buffer_ref (buffer.c:95)
==12602==    by 0x794FCD: av_packet_ref (avpacket.c:635)
==12602==    by 0x6E643B: ff_subtitles_queue_read_packet (subtitles.c:219)
==12602==    by 0x561D48: ass_read_packet (assdec.c:174)
==12602==    by 0x6FE05A: ff_read_packet (utils.c:827)
==12602==    by 0x569474: read_gab2_sub (avidec.c:1138)
==12602==    by 0x56A619: avi_read_packet (avidec.c:1495)
==12602==    by 0x6FE05A: ff_read_packet (utils.c:827)
==12602==    by 0x7011F0: read_frame_internal (utils.c:1529)
==12602==    by 0x709592: avformat_find_stream_info (utils.c:3794)
==12602==    by 0x22D4C9: open_input_file (ffmpeg_opt.c:1195)
==12602==    by 0x23BC31: open_files (ffmpeg_opt.c:3318)
==12602==    by 0x23BDE5: ffmpeg_parse_options (ffmpeg_opt.c:3358)
==12602==    by 0x25B809: main (ffmpeg.c:4959)
==12602== 
==12602== Invalid free() / delete / delete[] / realloc()
==12602==    at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12602==    by 0x122297A: av_free (mem.c:224)
==12602==    by 0x12229C2: av_freep (mem.c:234)
==12602==    by 0x120834D: buffer_replace (buffer.c:117)
==12602==    by 0x12083D7: av_buffer_unref (buffer.c:130)
==12602==    by 0x794E97: av_packet_unref (avpacket.c:609)
==12602==    by 0x795651: avpriv_packet_list_free (avpacket.c:789)
==12602==    by 0x7026A2: flush_packet_queue (utils.c:1833)
==12602==    by 0x70C29B: avformat_close_input (utils.c:4484)
==12602==    by 0x24A207: ffmpeg_cleanup (ffmpeg.c:626)
==12602==    by 0x241A25: exit_program (cmdutils.c:136)
==12602==    by 0x25B89C: main (ffmpeg.c:4972)
==12602==  Address 0x16a46dc0 is 0 bytes inside a block of size 24 free'd
==12602==    at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12602==    by 0x122297A: av_free (mem.c:224)
==12602==    by 0x12229C2: av_freep (mem.c:234)
==12602==    by 0x120834D: buffer_replace (buffer.c:117)
==12602==    by 0x12083D7: av_buffer_unref (buffer.c:130)
==12602==    by 0x794E97: av_packet_unref (avpacket.c:609)
==12602==    by 0x6FDF58: ff_read_packet (utils.c:808)
==12602==    by 0x569798: get_subtitle_pkt (avidec.c:1183)
==12602==    by 0x56A3E4: avi_read_packet (avidec.c:1452)
==12602==    by 0x6FE05A: ff_read_packet (utils.c:827)
==12602==    by 0x7011F0: read_frame_internal (utils.c:1529)
==12602==    by 0x709592: avformat_find_stream_info (utils.c:3794)
==12602==    by 0x22D4C9: open_input_file (ffmpeg_opt.c:1195)
==12602==    by 0x23BC31: open_files (ffmpeg_opt.c:3318)
==12602==    by 0x23BDE5: ffmpeg_parse_options (ffmpeg_opt.c:3358)
==12602==    by 0x25B809: main (ffmpeg.c:4959)
==12602==  Block was alloc'd at
==12602==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12602==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12602==    by 0x12225DC: av_malloc (mem.c:86)
==12602==    by 0x12229F1: av_mallocz (mem.c:239)
==12602==    by 0x1208296: av_buffer_ref (buffer.c:95)
==12602==    by 0x794FCD: av_packet_ref (avpacket.c:635)
==12602==    by 0x6E643B: ff_subtitles_queue_read_packet (subtitles.c:219)
==12602==    by 0x561D48: ass_read_packet (assdec.c:174)
==12602==    by 0x6FE05A: ff_read_packet (utils.c:827)
==12602==    by 0x569474: read_gab2_sub (avidec.c:1138)
==12602==    by 0x56A619: avi_read_packet (avidec.c:1495)
==12602==    by 0x6FE05A: ff_read_packet (utils.c:827)
==12602==    by 0x7011F0: read_frame_internal (utils.c:1529)
==12602==    by 0x709592: avformat_find_stream_info (utils.c:3794)
==12602==    by 0x22D4C9: open_input_file (ffmpeg_opt.c:1195)
==12602==    by 0x23BC31: open_files (ffmpeg_opt.c:3318)
==12602==    by 0x23BDE5: ffmpeg_parse_options (ffmpeg_opt.c:3358)
==12602==    by 0x25B809: main (ffmpeg.c:4959)



[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Nations do behave wisely once they have exhausted all other alternatives. 
-- Abba Eban
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210203/8efe31dc/attachment.sig>


More information about the ffmpeg-devel mailing list