New submission from Vladimir Eremeev <[EMAIL PROTECTED]>:

Below is the simple code, reading from a file and dropping 
read data. The file contains a dump of the MPEG2 Transport 
Stream.

Unfortunately, I cannot upload a file with the transport stream, as the 
host upload.mplayer.hu cannot be resolved.
However, this is the same file as I've uploaded in relation to the 
issue 430.

The C source is also the same.

Valgrind output: 
$ valgrind --tool=memcheck --leak-check=full --show-reachable=yes --
leak-resolution=high ./
mf_read                                                                         
                               
==4768== Memcheck, a memory error 
detector.                                                                       
            
==4768== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et 
al.                                                      
==4768== Using LibVEX rev 1804, a library for dynamic binary 
translation.                                                     
==4768== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks 
LLP.                                                            
==4768== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation 
framework.                                             
==4768== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et 
al.                                                      
==4768== For more details, rerun with: -
v                                                                               
      
==4768==                                                                        
                                              
input format: mpegts 
(0x476ef20)                                                                     
                         
av_open_input_stream, 
ret=0                                                                           
                        
av_find_stream_info, 
ret=0                                                                           
                         
packets read: 
1000                                                                            
                                
finished                                                                        
                                              
==4768==                                                                        
                                              
==4768== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 27 from 
1)                                                      
==4768== malloc/free: in use at exit: 32,320 bytes in 101 
blocks.                                                             
==4768== malloc/free: 41,589 allocs, 41,488 frees, 22,349,336 bytes 
allocated.                                                
==4768== For counts of detected errors, rerun with: -
v                                                                        
==4768== searching for pointers to 101 not-freed 
blocks.                                                                      
==4768== checked 2,882,520 
bytes.                                                                          
                   
==4768==                                                                        
                                              
==4768== 960 bytes in 3 blocks are definitely lost in loss record 1 of 
3                                                      
==4768==    at 0x4021A92: memalign 
(vg_replace_malloc.c:460)                                                       
           
==4768==    by 0x477753A: av_malloc 
(mem.c:61)                                                                      
          
==4768==    by 0x47775C8: av_mallocz 
(mem.c:134)                                                                     
         
==4768==    by 0x47246D5: add_pes_stream 
(mpegts.c:1015)                                                                 
     
==4768==    by 0x4723B35: pmt_cb 
(mpegts.c:640)                                                                  
             
==4768==    by 0x4722F61: write_section_data 
(mpegts.c:272)                                                                  
 
==4768==    by 0x47249F8: handle_packet 
(mpegts.c:1095)                                                                 
      
==4768==    by 0x4724C21: handle_packets 
(mpegts.c:1169)                                                                 
     
==4768==    by 0x472500F: mpegts_read_header 
(mpegts.c:1269)                                                                 
 
==4768==    by 0x46D876F: av_open_input_stream 
(utils.c:469)                                                                  
==4768==    by 0x46D8A95: av_open_input_file 
(utils.c:565)                                                                   
 
==4768==    by 0x8048878: main 
(mf_read.c:31)                                                                  
               
==4768==                                                                        
                                              
==4768==                                                                        
                                              
==4768== 10,880 bytes in 34 blocks are definitely lost in loss record 2 
of 3                                                  
==4768==    at 0x4021A92: memalign (vg_replace_malloc.c:460)
==4768==    by 0x477753A: av_malloc (mem.c:61)
==4768==    by 0x47775C8: av_mallocz (mem.c:134)
==4768==    by 0x47246D5: add_pes_stream (mpegts.c:1015)
==4768==    by 0x4723B35: pmt_cb (mpegts.c:640)
==4768==    by 0x4722F61: write_section_data (mpegts.c:272)
==4768==    by 0x47249BF: handle_packet (mpegts.c:1090)
==4768==    by 0x4724C21: handle_packets (mpegts.c:1169)
==4768==    by 0x472500F: mpegts_read_header (mpegts.c:1269)
==4768==    by 0x46D876F: av_open_input_stream (utils.c:469)
==4768==    by 0x46D8A95: av_open_input_file (utils.c:565)
==4768==    by 0x8048878: main (mf_read.c:31)
==4768==
==4768==
==4768== 20,480 bytes in 64 blocks are definitely lost in loss record 3 
of 3
==4768==    at 0x4021A92: memalign (vg_replace_malloc.c:460)
==4768==    by 0x477753A: av_malloc (mem.c:61)
==4768==    by 0x47775C8: av_mallocz (mem.c:134)
==4768==    by 0x47246D5: add_pes_stream (mpegts.c:1015)
==4768==    by 0x47247FC: handle_packet (mpegts.c:1045)
==4768==    by 0x4724C21: handle_packets (mpegts.c:1169)
==4768==    by 0x4725668: mpegts_read_packet (mpegts.c:1386)
==4768==    by 0x46D8C57: av_read_packet (utils.c:615)
==4768==    by 0x46DA1AA: av_read_frame_internal (utils.c:984)
==4768==    by 0x46DD9CD: av_find_stream_info (utils.c:2060)
==4768==    by 0x8048899: main (mf_read.c:33)
==4768==
==4768== LEAK SUMMARY:
==4768==    definitely lost: 32,320 bytes in 101 blocks.
==4768==      possibly lost: 0 bytes in 0 blocks.
==4768==    still reachable: 0 bytes in 0 blocks.
==4768==         suppressed: 0 bytes in 0 blocks.

$ ffmpeg
FFmpeg version SVN-r14775, Copyright (c) 2000-2008 Fabrice Bellard, et 
al.
  configuration: --disable-optimizations --disable-static --enable-
shared --disable-stripping --disable-mmx --disable-mmx2 --disable-ssse3 
--enable-debug=3 --cpu=i686 --extra-cflags=-O0 -fno-inline --prefix=/
home/wl                                     
  libavutil     49. 9. 0 / 49. 9. 
0                                                                               
            
  libavcodec    51.64. 0 / 51.64. 
0                                                                               
            
  libavformat   52.20. 0 / 52.20. 
0                                                                               
            
  libavdevice   52. 1. 0 / 52. 1. 
0                                                                               
            
  built on Aug 15 2008 18:29:38, gcc: 4.2.3 (Ubuntu 4.2.3-2ubuntu7)     

file mf_read.c

#include <stdio.h>
#include <string.h>

#include "libavcodec/avcodec.h"
#include "libavutil/avutil.h"
#include "libavformat/avformat.h"

int main(void)
{AVFormatContext *input=NULL;
 AVFormatParameters ap;
 AVPacket pkt;
 int bqsize=0,r;
 unsigned long pread=0;


        av_register_all();
        av_log_level=AV_LOG_DEBUG;
        input=av_alloc_format_context();
        input->iformat=av_find_input_format("mpegts");
        printf("input format: %s (%p)\n",input->iformat->name,input-
>iformat);

        input->flags|=AVFMT_FLAG_IGNIDX;
        //input->flags&=~AVFMT_FLAG_GENPTS;
        input->max_index_size=1024*50;
        input->max_picture_buffer=1024*100;

        memset(&ap, 0, sizeof(ap));
        ap.prealloced_context=1;
    r=av_open_input_file(&input,"issue430_wl2776_dump.ts",input-
>iformat,0,&ap);
        printf("av_open_input_stream, ret=%d\n",r);
        r=av_find_stream_info(input);
        printf("av_find_stream_info, ret=%d\n",r);
    input->pb->is_streamed=1;

    r=0;
    av_init_packet(&pkt);
        while(r==0){
                r = av_read_frame(input,&pkt);
        pread++;
        if(!(pread%1000)) printf("packets read: %lu     \r",pread);
        av_free_packet(&pkt);
        //av_destruct_packet(&pkt);
        }
    puts("\nfinished");
    av_close_input_file(input);

    return 0;
}

----------
messages: 2795
nosy: wl2776
priority: normal
status: new
substatus: new
title: memory leak in MPEG TS demuxer
type: bug

______________________________________________________
FFmpeg issue tracker <[EMAIL PROTECTED]>
<https://roundup.mplayerhq.hu/roundup/ffmpeg/issue584>
______________________________________________________

Reply via email to