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,
};
}
}