develooper Front page | perl.perl5.porters | Postings from February 2008

Re: [perl #51092] [PATCH] Segfault when calling ->next::method on non-existing package

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
February 25, 2008 02:55
Subject:
Re: [perl #51092] [PATCH] Segfault when calling ->next::method on non-existing package
Message ID:
b77c1dce0802250255o5beb53a1l4701b26f7ae61e72@mail.gmail.com
On 25/02/2008, Rafael Garcia-Suarez <rgarciasuarez@gmail.com> wrote:
> Thanks for this patch. Another alternative would be probably to
>  autovivify the package name, if possible.

That's what I applied :

Change 33367 by rgs@stcosmo on 2008/02/25 10:54:47

	Avoid a segfault case in MRO code, based on :
	
	Subject: [perl #51092] [PATCH] Segfault when calling ->next::method
on non-existing package
	From: ilmari@vesla.ilmari.org (via RT) <perlbug-followup@perl.org>
	Date: Thu, 21 Feb 2008 20:29:42 -0800
	Message-ID: <rt-3.6.HEAD-15287-1203654581-377.51092-75-0@perl.org>

Affected files ...

... //depot/perl/mro.c#46 edit
... //depot/perl/t/mro/next_edgecases.t#2 edit

Differences ...

==== //depot/perl/mro.c#46 (text) ====

@@ -954,7 +954,7 @@
     if(sv_isobject(self))
         selfstash = SvSTASH(SvRV(self));
     else
-        selfstash = gv_stashsv(self, 0);
+        selfstash = gv_stashsv(self, GV_ADD);

     assert(selfstash);


==== //depot/perl/t/mro/next_edgecases.t#2 (text) ====

@@ -3,7 +3,7 @@
 use strict;
 use warnings;

-require q(./test.pl); plan(tests => 11);
+require q(./test.pl); plan(tests => 12);

 {

@@ -78,5 +78,16 @@

         eval { $baz->bar() };
         ok($@, '... calling bar() with next::method failed') || diag $@;
-    }
+    }
+
+    # Test with non-existing class (used to segfault)
+    {
+        package Qux;
+        use mro;
+        sub foo { No::Such::Class->next::can }
+    }
+
+    eval { Qux->foo() };
+    is($@, '', "->next::can on non-existing package name");
+
 }

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About