This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop uninit sort warnings from crashing
authorFather Chrysostomos <sprout@cpan.org>
Fri, 14 Oct 2011 03:25:39 +0000 (20:25 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 14 Oct 2011 03:26:49 +0000 (20:26 -0700)
commit1aa032b25ab39eebe4a452ff935a39107a322a5b
tree589ddfca325b1179d45c5f9032d9f30bdba54fdb
parent7c1b9f38fcbfdb3a9e1766e02bcb991d1a5452d9
Stop uninit sort warnings from crashing

Commit d4c6760a made the warning in cases like this mention the
sort operator:

$ ./miniperl -we '()=sort { undef } 1,2'
Use of uninitialized value [in sort] at -e line 1.

It did so by setting PL_op during the SvIV(retval of sort block).  But
sv.c:S_find_uninit_var, called by report_uninit, tries to access the
targets of some ops, which are in PL_curpad on threaded builds.  In
the case of a sort sub (rather than an inlined block), PL_curpad con-
tained whatever was left over from the sort block (I presume, but
have not confirmed; in any case what is in PL_curpad is bad), causing
find_uninit_var to crash.

This commit sets PL_curpad to null and puts a check for it in
report_uninit.

It did not crash in debugging threaded builds, but that was probably
luck (even though I don’t believe in it).
pp_sort.c
sv.c