Skip Menu |
 

This queue is for tickets about the Carp CPAN distribution.

Report information
The Basics
Id: 72467
Status: open
Priority: 0/
Queue: Carp

People
Owner: Nobody in particular
Requestors: sewi [...] cpan.org
Cc: ether [...] cpan.org
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.22
  • 1.23
Fixed in: (no value)



Subject: panic: attempt to copy freed scalar
Download (untitled) / with headers
text/plain 344b
perl -MCarp -le 'f(@ARGV); sub f { my $x = shift(@ARGV); carp($x)}' a v panic: attempt to copy freed scalar 183d588 to 1854078 at /usr/share/ perl/5.12/Carp.pm line 104. Carp's crash looses the original error message and all additional information. I don't know how, but Carp should catch this error and report everything which is possible.
Download (untitled) / with headers
text/plain 311b
Using $_[0]; in line 182 seems to fix the problem: # Transform an argument to a function into a string. sub format_arg { my $arg = $_[0]; shift; if ( ref($arg) ) { perl -I. -MCarp -le 'f(@ARGV); sub f { my $x = shift(@ARGV); carp($x)}' a v a at -e line 1 main::f(undef, 'v') called at -e line 1
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #72467] panic: attempt to copy freed scalar
Date: Sat, 19 Nov 2011 23:13:10 +0000
To: Sebastian Willing via RT <bug-Carp [...] rt.cpan.org>
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 764b
Sebastian Willing via RT wrote: Show quoted text
>Using $_[0]; in line 182 seems to fix the problem:
Not really, since you're getting undef rather than the actual argument. Getting undef consistently in place of a freed argument would be OK, but I think you're only getting undef by accident. There's obviously a core bug, possibly two, behind this. I've reported the two core issues as [perl #104074] and [perl #104076]. The former, involving @DB::args, may be merely a consequence of the latter, a simpler issue with freed sub args. In the latter, a missing sub arg certainly can be accidentally replaced by something other than undef. I'm going to wait until the core issue is understood before deciding what, if anything, Carp should do. Thanks for the report. -zefram
Download (untitled) / with headers
text/plain 678b
On Sat Nov 19 18:13:21 2011, zefram@fysh.org wrote: Show quoted text
> > I'm going to wait until the core issue is understood before deciding what, > if anything, Carp should do.
It has been a long wait. I get "Bizarre copy of ARRAY" for which there's a concise summary at http://www.gossamer-threads.com/lists/perl/porters/227639 My band-aid is to turn this (in Carp.pm or Heavy.pm depending on version): my @args = map {Carp::format_arg($_)} @DB::args; Into this: my @args = eval { local $@; map {Carp::format_arg($_)} @DB::args; }; Then I at least get the sensible error that triggered carp/confess/etc. in the first place, and not the 'bizarre' error that tells me nothing useful.
Download (untitled) / with headers
text/plain 631b
On Fri Apr 13 19:53:19 2012, DOUGW wrote: Show quoted text
> On Sat Nov 19 18:13:21 2011, zefram@fysh.org wrote:
> > > > I'm going to wait until the core issue is understood before deciding
what, Show quoted text
> > if anything, Carp should do.
Show quoted text
> my @args = map {Carp::format_arg($_)} @DB::args; > > Into this: > > my @args = eval { > local $@; > map {Carp::format_arg($_)} @DB::args; > };
I think with the above fix you should at least be able to close the Carp bug, while keeping the many related bugs in perl itself open. Or maybe the eval belongs inside the map? (not tested): my @args = map { eval { local $@; Carp::format_arg($_) } } @DB::args; ??
Download (untitled) / with headers
text/plain 368b
On Sat Apr 14 13:53:47 2012, DOUGW wrote: Show quoted text
> > my @args = map { eval { local $@; Carp::format_arg($_) } } @DB::args;
Die'ing inside the eval returns an empty array, so you lose an argument in @args. So even better so that you know you lost an argument (IMHO): @args = map { my $tmp = eval { Carp::format_arg($_) }; defined($tmp) ? $tmp : 'unknown'; } @DB::args;
Download (untitled) / with headers
text/plain 304b
On Wed Apr 18 11:34:19 2012, DOUGW wrote: Show quoted text
> > @args = map { > my $tmp = eval { Carp::format_arg($_) }; > defined($tmp) ? $tmp : 'unknown'; > } @DB::args;
Forgot the local $@: @args = map { local $@; my $tmp = eval { Carp::format_arg($_) }; defined($tmp) ? $tmp : 'unknown'; } @DB::args;
Download (untitled) / with headers
text/plain 263b
A library that is supposed to report errors erroring out itself is a sad thing. Here is my fix to make the world a little less sad: my @args = map { local $@; my $tmp = eval { Carp::format_arg($_) }; defined($tmp) ? $tmp : 'unknown'; } @DB::args;


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.