Index | Thread | Search

From:
George Koehler <kernigh@gmail.com>
Subject:
Re: [patch] Re: OpenBSD perl 5.42.0 - Call for Testing
To:
Andrew Hewus Fresh <andrew@afresh1.com>
Cc:
James Cook <falsifian@falsifian.org>, tech@openbsd.org
Date:
Thu, 8 Jan 2026 20:58:27 -0500

Download raw body.

Thread
On Sat, 3 Jan 2026 10:34:02 -0800
Andrew Hewus Fresh <andrew@afresh1.com> wrote:

> On Sat, Jan 03, 2026 at 05:29:03PM +0000, James Cook wrote:
> > 
> > 	perl -c -wE 'for my ($x, $y) (Bar->foo) {}'
> > 
> > This causes perl 5.42.0 to segfault. Perl 5.40.0 says "-e syntax OK".
> > 
> > I've included the upstream fix as a patch. I would be grateful if it
> > could be included in the next OpenBSD release.
> 
> Seems like a good idea, I'll read more about it and test it out.

I applied the diff from James's mail, built it on macppc, and make
regress says, "All tests successful."  ok gkoehler, but I will let
afresh1 decide whether to commit it.

I see the same diff in pkgsrc and gentoo linux.
--gkoehler

> > diff /usr/src
> > path + /usr/src
> > commit - 287000ffa12fe34ef71791da513207ea48a4b740
> > blob - f616532c491cebc2d5dc89f124135ff4a9841281
> > file + gnu/usr.bin/perl/op.c
> > --- gnu/usr.bin/perl/op.c
> > +++ gnu/usr.bin/perl/op.c
> > @@ -9665,7 +9665,7 @@ S_op_is_cv_xsub(pTHX_ OP *o, XSUBADDR_t xsub)
> >          }
> >  
> >          case OP_PADCV:
> > -            cv = (CV *)PAD_SVl(o->op_targ);
> > +            cv = find_lexical_cv(o->op_targ);
> >              assert(cv && SvTYPE(cv) == SVt_PVCV);
> >              break;
> >  
> > @@ -9683,10 +9683,18 @@ S_op_is_cv_xsub(pTHX_ OP *o, XSUBADDR_t xsub)
> >  static bool
> >  S_op_is_call_to_cv_xsub(pTHX_ OP *o, XSUBADDR_t xsub)
> >  {
> > -    if(o->op_type != OP_ENTERSUB)
> > +    if (o->op_type != OP_ENTERSUB)
> >          return false;
> >  
> > -    OP *cvop = cLISTOPx(cUNOPo->op_first)->op_last;
> > +    /* entersub may be a UNOP, not a LISTOP, so we can't just use op_last */
> > +    OP *aop = cUNOPo->op_first;
> > +    if (!OpHAS_SIBLING(aop)) {
> > +        aop = cUNOPx(aop)->op_first;
> > +    }
> > +    aop = OpSIBLING(aop);
> > +    OP *cvop;
> > +    for (cvop = aop; OpHAS_SIBLING(cvop); cvop = OpSIBLING(cvop)) ;
> > +
> >      return op_is_cv_xsub(cvop, xsub);
> >  }
> >  
> > commit - 287000ffa12fe34ef71791da513207ea48a4b740
> > blob - 2f6790aee7758e16c2c86374648e22a9304ca4fe
> > file + gnu/usr.bin/perl/t/op/for-many.t
> > --- gnu/usr.bin/perl/t/op/for-many.t
> > +++ gnu/usr.bin/perl/t/op/for-many.t
> > @@ -498,4 +498,17 @@ is($continue, 'xx', 'continue reached twice');
> >      is("@have", "Pointy end Up Flamey end Down", 'for my ($one, $two)');
> >  }
> >  
> > +# GH #23405 - segfaults when compiling 2-var for loops
> > +{
> > +    my $dummy = sub {};
> > +    for my ($x, $y) (main->$dummy) {}
> > +    pass '2-var for does not crash on method calls';
> > +
> > +    my sub dummy {}
> > +    sub {
> > +        for my ($x, $y) (dummy) {}
> > +    }->();
> > +    pass '2-var for does not crash on lexical sub calls';
> > +}
> > +
> >  done_testing();