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

Re: [perl #21347] segfault in UNIVERSAL::AUTOLOAD

Thread Previous | Thread Next
From:
Enache Adrian
Date:
February 24, 2003 13:42
Subject:
Re: [perl #21347] segfault in UNIVERSAL::AUTOLOAD
Message ID:
20030224214247.GA891@ratsnest.hole
On Mon, Feb 24, 2003 at 10:17:44PM +0100, Rafael Garcia-Suarez wrote:
> > 1) Completely drop the 'Regexp' stash trick. Let $a = qr/../ be
> > a simple reference. Hack sv_reftype to return "Regexp" if the SV
> > its argument points to is a 'r'-magical variable.
> 
> You can try this to see what breaks. From what I can see, some
> adjustements may be needed in Data::Dumper. However I think this is a
> cleaner solution than :

I already did it and got no test failures. Unfortunately, the real
patch is above your local ${"FOO"} patch and my recent 3 patches
to Ton Hospels's bug reports. This is manually modified:

-------------------------------------------------------------------------
--- /arc/perl-current/sv.c	2003-02-18 04:01:51.000000000 +0200
+++ sv.c	2003-02-24 21:13:32.000000000 +0200
@@ -2964,9 +2964,7 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv,
 		
 		switch (SvTYPE(sv)) {
 		case SVt_PVMG:
-		    if ( ((SvFLAGS(sv) &
-			   (SVs_OBJECT|SVf_OK|SVs_GMG|SVs_SMG|SVs_RMG))
-			  == (SVs_OBJECT|SVs_RMG))
+		    if ( SvFLAGS(sv) & SVs_RMG
 			 && (mg = mg_find(sv, PERL_MAGIC_qr))) {
 			regexp *re = (regexp *)mg->mg_obj;
 
@@ -7650,6 +7648,9 @@ Perl_sv_reftype(pTHX_ SV *sv, int ob)
 	case SVt_PVIV:
 	case SVt_PVNV:
 	case SVt_PVMG:
+				if (SvFLAGS(sv) & SVs_RMG
+					&& mg_find(sv,PERL_MAGIC_qr))
+				    return "Regexp";
 	case SVt_PVBM:
 	    			if (SvVOK(sv))
 				    return "VSTRING";
--- /arc/perl-current/pp_hot.c	2003-02-16 17:05:00.000000000 +0200
+++ pp_hot.c	2003-02-24 22:42:27.000000000 +0200
@@ -1137,7 +1137,7 @@ PP(pp_qr)
     dSP;
     register PMOP *pm = cPMOP;
     SV *rv = sv_newmortal();
-    SV *sv = newSVrv(rv, "Regexp");
+    SV *sv = newSVrv(rv, Nullch);
     if (pm->op_pmdynflags & PMdf_TAINTED)
         SvTAINTED_on(rv);
     sv_magic(sv,(SV*)ReREFCNT_inc(PM_GETRE(pm)), PERL_MAGIC_qr,0,0);
--- /arc/perl-current/ext/Devel/Peek/Peek.t	2003-02-23 15:18:12.000000000 +0200
+++ ext/Devel/Peek/Peek.t	2003-02-24 21:35:09.000000000 +0200
@@ -264,15 +264,14 @@ do_test(15,
   RV = $ADDR
   SV = PVMG\\($ADDR\\) at $ADDR
     REFCNT = 1
-    FLAGS = \\(OBJECT,RMG\\)
+    FLAGS = \\(RMG\\)
     IV = 0
     NV = 0
     PV = 0
     MAGIC = $ADDR
       MG_VIRTUAL = $ADDR
       MG_TYPE = PERL_MAGIC_qr\(r\)
-      MG_OBJ = $ADDR
-    STASH = $ADDR\\t"Regexp"');
+      MG_OBJ = $ADDR');
 
 do_test(16,
         (bless {}, "Tac"),
-----------------------------------------------------------------------

I wonder however if someone has tried outside of the Perl core to
use to 'Regexp' stash ( put methods on it , etc ).

Regards

Adi

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