Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-StackTrace CPAN distribution.

Report information
The Basics
Id: 50447
Status: resolved
Priority: 0/
Queue: Devel-StackTrace

People
Owner: Nobody in particular
Requestors: Alexandre.Gorobets [...] gmail.com
Cc:
AdminCc:

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



Subject: Bizzare copy of **** in stack args
Simple (but awful) code, that raise error: use Devel::StackTrace; sub do_work { my $s = Devel::StackTrace->new( 'no_refs' => 1, ); } sub call_with_args { my ($arg_hash, $func) = @_; $func->( @{$arg_hash->{'args'}} ); } my $h = {}; my $arg_hash = { 'args' => [ undef ] }; call_with_args( $arg_hash, sub { $arg_hash->{'args'} = []; do_work( sub { $h; } ); } ); I propose this solution (in StackTrace.pm) sub _record_caller_data { my $self = shift; # We exclude this method by starting one frame back. my $x = 1; while ( my @c = do { package DB; @DB::args = (); caller($x++) } ) { my @args; foreach ( @DB::args ) { my $arg; local $@; eval { $arg = $self->{'no_refs'} && ref $_ ? $self->_ref_to_string( $_ ) : $_; }; if ( $@ =~ /^Bizarre copy of \w+/ ) { $arg = $&; } push @args, $arg; } push @{ $self->{raw} }, { 'caller' => \@c, 'args' => \@args, }; } }
On Tue Oct 13 10:12:36 2009, AlexandreGorobets wrote: Show quoted text
> Simple (but awful) code, that raise error: > > use Devel::StackTrace; > > sub do_work { > my $s = Devel::StackTrace->new( > 'no_refs' => 1, > ); > } > > sub call_with_args { > my ($arg_hash, $func) = @_; > $func->( @{$arg_hash->{'args'}} ); > } > > my $h = {}; > > my $arg_hash = { 'args' => [ undef ] }; > > call_with_args( > $arg_hash, sub { > $arg_hash->{'args'} = []; > do_work( sub { $h; } ); > } > ); > > > I propose this solution (in StackTrace.pm) > > sub _record_caller_data > { > my $self = shift; > > # We exclude this method by starting one frame back. > my $x = 1; > while ( my @c = > do { package DB; @DB::args = (); caller($x++) } ) > { > my @args; > > foreach ( @DB::args ) > { > my $arg; > > local $@; > > eval > { > $arg = $self->{'no_refs'} && ref $_ ? $self-
> >_ref_to_string( $_ ) : $_;
> }; > > if ( $@ =~ /^Bizarre copy of \w+/ ) > { > $arg = $&; > } > > push @args, $arg; > } > > push @{ $self->{raw} }, > { 'caller' => \@c, > 'args' => \@args, > }; > } > }
Sorry for the slow reply. This is really a bug in the Perl core, and should probably be reported there. As for a hackaround in Devel::StackTrace, any such thing would need to _not_ use $& to be useful.
From: ghewson [...] wormhole.me.uk
On Sat Jun 26 15:55:57 2010, DROLSKY wrote: Show quoted text
> This is really a bug in the Perl core, and should probably be
reported Show quoted text
> there.
I've just submitted a report to perlbug@perl.org. I've written a stripped-down amalgamation of Alexandre's test case and Devel::StackTrace, which I attach here. Graeme Hewson
Subject: bizarre
Download bizarre
application/x-perl 916b

Message body not shown because it is not plain text.

From: ghewson [...] wormhole.me.uk
From: ghewson [...] wormhole.me.uk
OK, so the core problem is not realistically fixable. It seems a workaround is the best we could do. I don't know if this has any relevance, which I happened to notice in perl5134delta ("what is new for perl v5.13.4"): Show quoted text
> "Carp" > Upgraded from version 1.16 to 1.18.
Show quoted text
> Carp now detects incomplete caller() overrides and avoids using > bogus @DB::args. To provide backtraces, Carp relies on
particular Show quoted text
> behaviour of the caller built-in. Carp now detects if other code > has overridden this with an incomplete implementation, and
modifies Show quoted text
> its backtrace accordingly. Previously incomplete overrides would > cause incorrect values in backtraces (best case), or obscure
fatal Show quoted text
> errors (worst case)
Show quoted text
> This fixes certain cases of "Bizarre copy of ARRAY" caused by > modules overriding "caller()" incorrectly.
RT-Send-CC: ghewson [...] wormhole.me.uk
Getting hit by this, too, via Perl 5.14.2. So, it's not really fixed in CORE, and it might never be. Since this thing is used for Exception::Class, I think whatever workaround that can be implemented should be. We certainly don't want stuff to crash on us DURING the Exception, before we even get to print it.
On Sun Apr 22 20:56:54 2012, BBYRD wrote: Show quoted text
> Getting hit by this, too, via Perl 5.14.2. So, it's not really fixed
in Show quoted text
> CORE, and it might never be. Since this thing is used for > Exception::Class, I think whatever workaround that can be implemented > should be. We certainly don't want stuff to crash on us DURING the > Exception, before we even get to print it.
A good patch would be welcome. Bonus points for stealing the code from Carp that fixes some of these bugs (but not all, I'm sure). I think the linked rt.perl ticket might provide a good test case.