Reset cx in pp_sort before POPSUB, as the pointer may no
longer be valid.
if (!(flags & OPf_SPECIAL)) {
SV *sv;
+ /* Reset cx, in case the context stack has been
+ reallocated. */
+ cx = &cxstack[cxstack_ix];
POPSUB(cx, sv);
LEAVESUB(sv);
}
require 'test.pl';
}
use warnings;
-plan( tests => 159 );
+plan( tests => 160 );
# these shouldn't hang
{
is($count, 0, 'all gone');
}
+
+# [perl #77930] The context stack may be reallocated during a sort, as a
+# result of deeply-nested (or not-so-deeply-nested) calls
+# from a custom sort subroutine.
+fresh_perl_is
+ '
+ $sub = sub {
+ local $count = $count+1;
+ ()->$sub if $count < 1000;
+ $a cmp $b
+ };
+ () = sort $sub qw<a b c d e f g>;
+ print "ok"
+ ',
+ 'ok',
+ {},
+ '[perl #_____] cx_stack reallocation during sort'
+;