develooper Front page | perl.perl5.porters | Postings from November 2000

Re: [ID 20000722.003] Perl: nested closure crashes on Linux

Benjamin Holzman
November 27, 2000 15:18
Re: [ID 20000722.003] Perl: nested closure crashes on Linux
Message ID:
I know what's wrong with

	sub a { }
	my @b;
	sub { a $b[0]; sub c { a $b[0] }; c }->();

from both the Perl level (declaring a global sub inside an anonymous codeblock
is dubious at best) and the C level (although the TARG for the padav in sub c
is correct, it ends up that PL_curpad is wrong [1 too high], and UNDEF gets put
on the stack instead of @b, which results in a segfault at AvFILL(av) in
pp_hot.c:2791 (perl@7892).  I can't quite figure out why.  @b has to be a
lexical array, the arguments to a() have to be padav aelems, it has to be
called from an anonymous codeblock and the first call to a() has to be lexically
before the subroutine definition.

Does anyone have any clue?

Benjamin Holzman				ECNvantage Corp.
Chief Technical Officer 			295 Park Avenue S., Suite 7C
(212) 358-0436 :		New York, NY, 10010
$ perl -le 'print join $" ,reverse map ucfirst ,qw{ hacker perl another just}' Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About