Fix for [perl #52074] Segfault on ISA push after symbol table delete
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 15 Apr 2008 08:36:48 +0000 (08:36 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 15 Apr 2008 08:36:48 +0000 (08:36 +0000)
This restores the 5.8.8 behaviour. The deleted stash is not vivified
again, hence the hierarchy remains broken. But there's no segfault.

p4raw-id: //depot/perl@33684

mg.c
t/mro/pkg_gen.t

diff --git a/mg.c b/mg.c
index 0bc7979..dfe1fb7 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1607,7 +1607,8 @@ Perl_magic_setisa(pTHX_ SV *sv, MAGIC *mg)
             : (GV*)SvMAGIC(mg->mg_obj)->mg_obj
     );
 
-    mro_isa_changed_in(stash);
+    if (stash)
+       mro_isa_changed_in(stash);
 
     return 0;
 }
@@ -1632,7 +1633,8 @@ Perl_magic_clearisa(pTHX_ SV *sv, MAGIC *mg)
             : (GV*)SvMAGIC(mg->mg_obj)->mg_obj
     );
 
-    mro_isa_changed_in(stash);
+    if (stash)
+       mro_isa_changed_in(stash);
 
     return 0;
 }
index 6a507ac..e1f5eb0 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 chdir 't' if -d 't';
-require q(./test.pl); plan(tests => 6);
+require q(./test.pl); plan(tests => 7);
 
 {
     package Foo;
@@ -34,3 +34,7 @@ is(mro::get_pkg_gen('Foo'), 1, "pkg_gen 1 for undef %Pkg::");
 
 delete $::{"Foo::"};
 is(mro::get_pkg_gen('Foo'), 0, 'pkg_gen 0 for delete $::{Pkg::}');
+
+delete $::{"Quux::"};
+push @Quux::ISA, "Woot"; # should not segfault
+ok(1, "No segfault on modification of ISA in a deleted stash");