One of the tests in sort.t causes a bus error (or sometimes ‘Undefined
subroutine called’) if run multiple times. This is because sort
decreases the refcount of an active sub used as a comparison routine.
Ironically enough, this test was added by the very change that broke it
(25953/9850bf2).
if (!(flags & OPf_SPECIAL)) {
cx->cx_type = CXt_SUB;
cx->blk_gimme = G_SCALAR;
+ /* If our comparison routine is already active (CvDEPTH is
+ * is not 0), then PUSHSUB does not increase the refcount,
+ * so we have to do it ourselves, because the LEAVESUB fur-
+ * ther down lowers it. */
+ if (CvDEPTH(cv)) SvREFCNT_inc_simple_void_NN(cv);
PUSHSUB(cx);
if (!is_xsub) {
AV* const padlist = CvPADLIST(cv);
require 'test.pl';
}
use warnings;
-plan( tests => 147 );
+plan( tests => 148 );
# these shouldn't hang
{
cmp_ok(substr($@,0,length($fail_msg)),'eq',$fail_msg,'undef active subr');
-
-{
+for(1,2) # We run this twice, to make sure sort does not lower the ref
+{ # count. See bug 71076.
my $failed = 0;
sub rec {