Skip Menu |

This queue is for tickets about the Object-Pad CPAN distribution.

Report information
The Basics
Id: 133258
Status: resolved
Priority: 0/
Queue: Object-Pad

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.32
Fixed in: 0.33



Calling ->begin_class on a package that does not exist yet seems to trigger SIGSEGV quite happily. Doing the same from an ->import loaded after the `package Example::Class` does not appear to hit any similar issues (have been using that construct quite a bit so if that can fail, it's rare enough that I have yet to see it happen!)
Subject: object-pad-segv.pl
#!/usr/bin/env perl use strict; use warnings; require Object::Pad; Object::Pad->import_into(my $pkg = 'Example::Class'); Object::Pad->begin_class($pkg);
On Tue Sep 01 09:30:08 2020, TEAM wrote: Show quoted text
> Calling ->begin_class on a package that does not exist yet seems to > trigger SIGSEGV quite happily.
An even shorter test case: $ perl -Mblib -MObject::Pad -e'Object::Pad->begin_class("Not::A::Package")' Segmentation fault -- Paul Evans
Same fix as for other case where PL_parser is NULL when calling newSTATEOP(). -- Paul Evans
Subject: rt133258.patch
=== modified file 'lib/Object/Pad.xs' --- old/lib/Object/Pad.xs 2020-09-03 19:27:15 +0000 +++ new/lib/Object/Pad.xs 2020-09-03 19:40:48 +0000 @@ -977,6 +977,8 @@ meta->type = type; meta->name = SvREFCNT_inc(name); + HV *stash = meta->stash = gv_stashsv(name, GV_ADD); + meta->sealed = false; meta->offset = 0; meta->slots = newAV(); @@ -989,13 +991,25 @@ meta->buildblocks = NULL; meta->initslots = NULL; + if(!PL_parser) { + /* We need to generate just enough of a PL_parser to keep newSTATEOP() + * happy, otherwise it will SIGSEGV (RT133258) + */ + SAVEVPTR(PL_parser); + Newxz(PL_parser, 1, yy_parser); + SAVEFREEPV(PL_parser); + + PL_parser->copline = NOLINE; +#if HAVE_PERL_VERSION(5, 20, 0) + PL_parser->preambling = NOLINE; +#endif + } + meta->tmpcop = (COP *)newSTATEOP(0, NULL, NULL); CopFILE_set(meta->tmpcop, __FILE__); meta->methodscope = NULL; - HV *stash = meta->stash = gv_stashsv(name, GV_ADD); - AV *isa; { SV *isaname = newSVpvf("%" SVf "::ISA", name);
Released in 0.33 -- Paul Evans