Skip Menu |
Report information
Id: 130496
Status: resolved
Priority: 0/
Queue: perl5

Owner: arc <arc [at] cpan.org>
Requestors: brian.carpenter [at] gmail.com
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



Subject: pp_hot.c:4468: HV *S_opmethod_stash(SV *) Assertion Failed.
From: "Brian 'geeknik' Carpenter" <brian.carpenter [...] gmail.com>
Date: Tue, 3 Jan 2017 12:59:45 -0600
To: perlbug [...] perl.org
Download (untitled) / with headers
text/plain 230b
Triggered with Perl v5.25.8-132-gc10193e while fuzzing with AFL.

./perl -e '{0>{}->$}}'
perl: pp_hot.c:4468: HV *S_opmethod_stash(SV *): Assertion `PL_valid_types_PVX[((svtype)((_svpvx)->sv_flags & 0xff)) & 0xf]' failed.
Aborted
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 645b
On Tue, 03 Jan 2017 11:00:44 -0800, brian.carpenter@gmail.com wrote: Show quoted text
> Triggered with Perl v5.25.8-132-gc10193e while fuzzing with AFL. > > ./perl -e '{0>{}->$}}' > perl: pp_hot.c:4468: HV *S_opmethod_stash(SV *): Assertion > `PL_valid_types_PVX[((svtype)((_svpvx)->sv_flags & 0xff)) & 0xf]' failed. > Aborted
This simplifies to: % ./miniperl -e '{}->$x' miniperl: pp_hot.c:4470: S_opmethod_stash: Assertion `PL_valid_types_PVX[((svtype)((_svpvx)->sv_flags & 0xff)) & 0xf]' failed. Aborted (core dumped) % The crash bisects to Dave's recent commit 9a70c74b "remove DOES's usage of SvSCREAM", I think we're missing a guard of some sort. Hugo
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.9k
When S_opmethod_stash() determines that the LHS is an unblessed reference, it generates an error message containing the method name. However, it was calling SvPVX() on the method name without ensuring that it's SvPOK(). The fix is straightforward, and is now in blead; see below. That said, I'm wondering whether we should special-case undefined method names, so as to produce better error messages. If we want to do that before 5.26, we've got about two weeks left before the "user-visible changes" freeze. commit 323dbd00f273d31c4a30b1de1a1201aea0f1b778 Author: Aaron Crane <arc@cpan.org> Date: Wed Jan 4 20:02:45 2017 +0000 RT#130496: assertion failure for '{}->$x' on undefined $x diff --git a/pp_hot.c b/pp_hot.c index dd2c611e1f..97d46f6511 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -4465,7 +4465,7 @@ S_opmethod_stash(pTHX_ SV* meth) && SvOBJECT(ob)))) { Perl_croak(aTHX_ "Can't call method \"%" SVf "\" on unblessed reference", - SVfARG((SvPVX(meth) == PL_isa_DOES) + SVfARG((SvPOK(meth) && SvPVX(meth) == PL_isa_DOES) ? newSVpvs_flags("DOES", SVs_TEMP) : meth)); } diff --git a/t/op/method.t b/t/op/method.t index 8795734ae4..ef181c4ce0 100644 --- a/t/op/method.t +++ b/t/op/method.t @@ -13,7 +13,7 @@ BEGIN { use strict; no warnings 'once'; -plan(tests => 150); +plan(tests => 151); @A::ISA = 'B'; @B::ISA = 'C'; @@ -704,6 +704,13 @@ SKIP: { "check unknown import() methods don't corrupt the stack"); } +# RT#130496: assertion failure when looking for a method of undefined name +# on an unblessed reference +fresh_perl_is('eval { {}->$x }; print $@;', + "Can't call method \"\" on unblessed reference at - line 1.", + {}, + "no crash with undef method name on unblessed ref"); + __END__ #FF9900 #F78C08 -- Aaron Crane ** http://aaroncrane.co.uk/
From: Dave Mitchell <davem [...] iabyn.com>
Date: Sat, 7 Jan 2017 14:17:22 +0000
To: Aaron Crane via RT <perlbug-followup [...] perl.org>
CC: perl5-porters [...] perl.org
Subject: Re: [perl #130496] pp_hot.c:4468: HV *S_opmethod_stash(SV *) Assertion Failed.
Download (untitled) / with headers
text/plain 659b
On Wed, Jan 04, 2017 at 12:20:51PM -0800, Aaron Crane via RT wrote: Show quoted text
> That said, I'm wondering whether we should special-case undefined method > names, so as to produce better error messages.
Well currently you get: $ perl -e'my $obj = bless []; my $meth; $obj->$meth' Can't locate object method "" via package "main" at -e line 1. $ perl -we'my $obj = bless []; my $meth; $obj->$meth' Use of uninitialized value $meth in method lookup at -e line 1. Can't locate object method "" via package "main" at -e line 1. $ which seems reasonably clear to me. -- If life gives you lemons, you'll probably develop a citric acid allergy.


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

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org