Stas Bekman wrote: [...]
Well Devel::Leak (in my CPAN directory) is what did when doing Tk.
It works by recording all the SVs in use at one point
and then comparing them at a later point. It can do sv_dump()s of the new ones.
Thanks for the reminder Nick, I forgot about this tool. but as you have you need to have a clue of where it comes from :( I'll keep on looking.
It doesn't seem to help in case where the leak happens in the ithread. You can't bracket with Devel::Leak::NoteSV and Devel::Leak::CheckSV around a thread, since both need to run inside that thread, but it's too late to bracket at the start and too late to bracket on exit.
You can for example take the ticket [perl #34341], where we already know that $0 leaks when the thread exists. Let's try to bracket around the thread:
#!/usr/bin/perl -T use Devel::Leak; use threads;
local $0 = "test"; # <== XXX: leaks scalar
Devel::Leak::NoteSV($handle);
my $thr = threads->new(sub { 1 });
$thr->join; # <== XXX: triggers the leak
Devel::Leak::CheckSV($handle);
% perl-5.8.7-ithread -T /tmp/leak new 0x80e1598 : SV = IV(0x80de84c) at 0x80e1598 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 134659032 new 0x80e15a4 : SV = PVMG(0x808a1d0) at 0x80e15a4 REFCNT = 1 FLAGS = (OBJECT,GMG,READONLY,pIOK) IV = 135194992 NV = 0 PV = 0 MAGIC = 0x813dbe0 MG_VIRTUAL = 0x4038ab54 MG_TYPE = PERL_MAGIC_shared_scalar(n) MG_FLAGS = 0x10 MG_PTR = 0x80ee970 "" STASH = 0x80664a8 "threads" old (1): 0 SV = UNKNOWN(0xff) (0x804cd0c) at 0x80e1490 REFCNT = 0 FLAGS = () Scalars leaked: 1 leaked: sv=0x8147b04 flags=0x084046007 refcnt=0, Perl interpreter: 0x80ee9b8
No help whatsover, since the leak happens inside the thread.
Also what does the following means? (output of CheckSV) old (1): 0 SV = UNKNOWN(0xff) (0x804cd0c) at 0x80e1490 REFCNT = 0 FLAGS = ()
does it mean that it has found some bogus scalar, or it just couldn't figure out what's the scalar?
Should there be a mechanism allowing us to register at the beginning of the thread and its exit? I suppose CLONE may help with the former (in case it's run before $0 is cloned), but I'm not sure if something similar can be done on exit. I've tried something like the following, trying to get as close as possible to the start/end of the thread.
#!/usr/bin/perl -T use Devel::Leak; use threads; use threads::shared;
my $handle : shared;
package Foo;
sub CLONE { Devel::Leak::NoteSV($handle) }
sub new { bless {}, __PACKAGE__ }
sub DESTROY { Devel::Leak::CheckSV($handle) }package main;
local $0 = 'mememe'; # <== XXX: leaks scalar
my $thr = threads->new(sub { Foo->new; 1 });
$thr->join; # <== XXX: triggers the leakbut it's not good enough, Devel::Leak::NoteSV runs after the leaked $0 was cloned. So at the moment there are no tools that I can use to trace bugs, which aren't in my code.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
