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

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

From:
Tony Cook via RT
Date:
December 15, 2015 05:42
Subject:
[perl #126872] panic: attempt to copy freed scalar
Message ID:
rt-4.0.18-5670-1450158140-1598.126872-15-0@perl.org
On Thu Dec 10 09:24:41 2015, kes-kes@yandex.ua 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/DebugHooks.pm 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.

Tony


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=126872



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About