develooper Front page | perl.perl5.porters | Postings from December 2015

[perl #126872] panic: attempt to copy freed scalar

Tony Cook via RT
December 15, 2015 05:42
[perl #126872] panic: attempt to copy freed scalar
Message ID:
On Thu Dec 10 09:24:41 2015, wrote:
> [Please describe your issue here]
> $ perl -d:KillPrint -e 0
> panic: attempt to copy freed scalar 2175990 to 2175600 at
> /home/kes/work/projects/perl_libs/Devel/ line 17.
> BEGIN failed--compilation aborted.

@DB::args is a very low-level copy of the subroutine arguments, it doesn't keep reference counts to those arguments, so if you use @DB::args when the sub call that was used to populate it has returned, its values are invalid.

Your code is attemptting to use values in @DB::args from the *previous* call to caller(), for which the subroutine has returned.

If you ensure caller() is called before you use @DB::args:
 sub frames {
     my $level =  shift;
     my @c = caller($level+1);
     return ( [ @DB::args ], @c )   if defined $level;

there's no crash.


via perlbug:  queue: perl5 status: new Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About