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



Download (untitled) / with headers
text/plain 333b
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
Download object-pad-segv.pl
text/x-perl 159b
#!/usr/bin/env perl use strict; use warnings; require Object::Pad; Object::Pad->import_into(my $pkg = 'Example::Class'); Object::Pad->begin_class($pkg);
Download (untitled) / with headers
text/plain 284b
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
Download rt133258.patch
text/x-diff 1k
=== 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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.