Re: libdvbv5: dvb_table_pat_init is leaking memory

2013-12-15 Thread Gregor Jasny

Hello Mauro,

On 28/11/13 13:24, Mauro Carvalho Chehab wrote:

After a good resting night, I reviewed it, and it turns that memory leaks
can occur.

So, I re-worked the logic. I also fixed the other bugs pointed by Coverity
today. Could you please re-run the Coverity tests, to see if everything is
OK with the current version?


I triggered a rebuild last night. Currently this is a manual process.

Hans, as far as I know you're automatically building the media tree and 
check for warnings. Could you also host the nightly Coverity run?

On my i7 it takes about a minute per run.

Thanks,
Gregor

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: libdvbv5: dvb_table_pat_init is leaking memory

2013-11-28 Thread Mauro Carvalho Chehab
Hi Gregor,

Em Wed, 27 Nov 2013 20:46:42 -0200
Mauro Carvalho Chehab m.che...@samsung.com escreveu:

 Em Wed, 27 Nov 2013 20:31:21 -0200
 Mauro Carvalho Chehab mche...@infradead.org escreveu:
 
  Hi Gregor,
  
  Em Wed, 27 Nov 2013 22:55:32 +0100
  Gregor Jasny gja...@googlemail.com escreveu:
  
   Hello,
   
   Coverity noticed that dvb_table_pat_init leaks the reallocated memory
   stored in pat:
   http://git.linuxtv.org/v4l-utils.git/blob/HEAD:/lib/libdvbv5/descriptors/pat.c#l26
   
   Mauro, could you please check?
  
  On my tests with Valgrind, I'm not noticing any memory leak there, at
  least on the very latest version I pushed today[1].

After a good resting night, I reviewed it, and it turns that memory leaks
can occur.

So, I re-worked the logic. I also fixed the other bugs pointed by Coverity
today. Could you please re-run the Coverity tests, to see if everything is
OK with the current version?

Thanks!
Mauro

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: libdvbv5: dvb_table_pat_init is leaking memory

2013-11-27 Thread Mauro Carvalho Chehab
Hi Gregor,

Em Wed, 27 Nov 2013 22:55:32 +0100
Gregor Jasny gja...@googlemail.com escreveu:

 Hello,
 
 Coverity noticed that dvb_table_pat_init leaks the reallocated memory
 stored in pat:
 http://git.linuxtv.org/v4l-utils.git/blob/HEAD:/lib/libdvbv5/descriptors/pat.c#l26
 
 Mauro, could you please check?

On my tests with Valgrind, I'm not noticing any memory leak there, at
least on the very latest version I pushed today[1].

I tested here with DVB-T, DVB-T2, DVB-S, DVB-S2 and DVB-C.

I didn't test the current version yet with ATSC or ISDB-T. Those are
on my todo list. I'll likely do ATSC test today or tomorrow.

ISDB-T test might take some time, as I'm having some troubles to test it
here those days.

That's said, I would love to get rid of that realloc() on PAT, but this
would break the existing userspace interface. So, such change, if done,
would require some care, as at least tvdaemon relies on it.

Regards,
Mauro

[1] Not sure if you noticed, but I added ~80 patches for it today.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: libdvbv5: dvb_table_pat_init is leaking memory

2013-11-27 Thread Mauro Carvalho Chehab
Em Wed, 27 Nov 2013 20:31:21 -0200
Mauro Carvalho Chehab mche...@infradead.org escreveu:

 Hi Gregor,
 
 Em Wed, 27 Nov 2013 22:55:32 +0100
 Gregor Jasny gja...@googlemail.com escreveu:
 
  Hello,
  
  Coverity noticed that dvb_table_pat_init leaks the reallocated memory
  stored in pat:
  http://git.linuxtv.org/v4l-utils.git/blob/HEAD:/lib/libdvbv5/descriptors/pat.c#l26
  
  Mauro, could you please check?
 
 On my tests with Valgrind, I'm not noticing any memory leak there, at
 least on the very latest version I pushed today[1].
 
 I tested here with DVB-T, DVB-T2, DVB-S, DVB-S2 and DVB-C.
 
 I didn't test the current version yet with ATSC or ISDB-T. Those are
 on my todo list. I'll likely do ATSC test today or tomorrow.
 
 ISDB-T test might take some time, as I'm having some troubles to test it
 here those days.
 
 That's said, I would love to get rid of that realloc() on PAT, but this
 would break the existing userspace interface. So, such change, if done,
 would require some care, as at least tvdaemon relies on it.
 
 Regards,
 Mauro
 
 [1] Not sure if you noticed, but I added ~80 patches for it today.

Gregor,

After looking into it inside coverity, I suspect that coverity is 
complaining because the code is:

pat = some_function(pat, size);

E. g. it is not understanding that realloc takes the original pointer
as an entry, and returns a pointer to the newer pointer with the bigger
size.

So, it thinks that the first memory allocated for pat is not visible
anymore, and it will leak.

FYI, this is the result of a DVB-C scanning (35 frequencies, each with its
own PAT table):

==16035== Memcheck, a memory error detector
==16035== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==16035== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==16035== Command: ./utils/dvb/dvbv5-scan -I channel /home/mchehab/dvbc-teste
==16035== 
ERRORcommand BANDWIDTH_HZ (5) not found during retrieve
INFO Scanning frequency #1 57300
Lock   (0x1f) Quality= Poor Signal= 100.00% C/N= 36.40dB UCB= 36535 postBER= 
1.34x10^-3 PER= 4.78x10^-3
==16035== Warning: noted but unhandled ioctl 0x6f2a with no size/direction hints
==16035==This could cause spurious value errors to appear.
==16035==See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a 
proper wrapper.
==16035== Warning: noted but unhandled ioctl 0x6f2a with no size/direction hints
==16035==This could cause spurious value errors to appear.
==16035==See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a 
proper wrapper.
==16035== Warning: noted but unhandled ioctl 0x6f2a with no size/direction hints
==16035==This could cause spurious value errors to appear.
==16035==See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a 
proper wrapper.
INFO Service SBT, provider (null): digital television
INFO Service Globo, provider Globo: digital television
INFO Service Record, provider (null): digital television
INFO Service Band, provider (null): digital television
INFO Service LBV - Rede Mundial, provider (null): digital television
INFO Service Cartoon Network, provider (null): digital television
INFO Service TNT, provider (null): digital television
INFO Service Boomerang, provider (null): digital television
INFO Service NET Games, provider (null): digital television
INFO Service NET Música, provider (null): digital television
INFO Service Pagode, provider (null): digital radio
INFO Service Axé, provider (null): digital radio
INFO Service Festa, provider (null): digital radio
INFO Service Trilhas Sonoras, provider (null): digital radio
INFO Service Rádio Globo RJ, provider (null): digital radio
INFO Service 01070138, provider (null): user defined
INFO Service 01070238, provider (null): user defined
INFO New transponder/channel found: #2: 71700
INFO New transponder/channel found: #3: 72300
INFO New transponder/channel found: #4: 54900
INFO New transponder/channel found: #5: 55500
INFO New transponder/channel found: #6: 56100
INFO New transponder/channel found: #7: 56700
INFO New transponder/channel found: #8: 43500
INFO New transponder/channel found: #9: 44100
INFO New transponder/channel found: #10: 44700
INFO New transponder/channel found: #11: 45300
INFO New transponder/channel found: #12: 45900
INFO New transponder/channel found: #13: 46500
INFO New transponder/channel found: #14: 47100
INFO New transponder/channel found: #15: 57900
INFO New transponder/channel found: #16: 58500
INFO New transponder/channel found: #17: 59100
INFO New transponder/channel found: #18: 59700
INFO New transponder/channel found: #19: 60300
INFO New transponder/channel found: #20: 60900
INFO New transponder/channel found: #21: 61500
INFO New transponder/channel found: #22: 62100