
davem at iabyn
May 11, 2008, 1:02 PM
Post #2 of 8
(1466 views)
Permalink
|
On Thu, May 08, 2008 at 05:00:06PM -0400, Jerry D. Hedden wrote: > While working on tests for some new threads::shared > functionality, my test code started generating: > > Attempt to free unreferenced scalar: SV 0x15193f8, Perl > interpreter: 0x14b2830 at ./leak.pl line 36. > Attempt to free unreferenced scalar: SV 0x15193c8, Perl > interpreter: 0x14b2830 at ./leak.pl line 36. > Scalars leaked: 2 > > The following (also attached) reproduces this in blead: > > #!/usr/bin/perl > use strict; > use warnings; > use threads; > use threads::shared; > > sub _bork { > return $_[0]; > } > > sub bork > { > if (@_ != 1) { > require Carp; > Carp::croak('Needs one and only one arg'); > } > return _bork(shift, {}); > } > > { > my %hsh = ('foo' => 2); > eval { > bork(%hsh); > }; > $@ = undef; > } > > my $foo :shared; > $foo = bork(\$foo); > > threads->create(sub { > $foo = 1; > })->join(); > > I can remove 'use strict' and 'use warnings' and still > reproduce the leak, but if I change anything else, the leak > goes away. > > Can anyone else reproduce this? If so, can anyone identify > what's leaking? I can reproduce. It can be simplified to: use threads; use threads::shared; sub bork { if (@_) { package DB; () = caller(0); } return {}; } { my %hsh = ('foo' => 2); eval { bork(%hsh); }; } my $foo :shared; bork(); threads->create(sub { $foo; })->join(); The two AV's that are being double-freed are the thread-cloned copies of the pad and pad-name AVs of the cloned anon sub passed as an arg to create(). I've run out of time to look at this any further for the moment. -- "Procrastination grows to fill the available time" -- Mitchell's corollary to Parkinson's Law
|