perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@ectoplasm.org>
Subject Re: [mp2] local %ENV causes Segmentation fault or Bus error
Date Fri, 16 Dec 2005 01:13:59 GMT
Philip M. Gollucci wrote:
>> You will only get the Seg fault or Bus error when a process comes round
>> for recycling.

This is basically caused by the assumption that %ENV will be tied, and local %ENV
breaks that assumption ;-S

The following patch fixes this problem for me:

Index: src/modules/perl/modperl_env.c
===================================================================
--- src/modules/perl/modperl_env.c      (revision 357090)
+++ src/modules/perl/modperl_env.c      (working copy)
@@ -15,8 +15,11 @@

 #include "mod_perl.h"

-#define EnvMgObj SvMAGIC((SV*)ENVHV)->mg_ptr
-#define EnvMgLen SvMAGIC((SV*)ENVHV)->mg_len
+#define EnvMgOK ((SV*)ENVHV && SvMAGIC((SV*)ENVHV))
+#define EnvMgObj (EnvMgOK ? SvMAGIC((SV*)ENVHV)->mg_ptr : NULL)
+#define EnvMgLen (EnvMgOK ? SvMAGIC((SV*)ENVHV)->mg_len : 0)
+#define EnvMgObjSet(val) { if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_ptr = val; }
+#define EnvMgLenSet(val) { if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_len = val; }

 /* XXX: move to utils? */
 static unsigned long modperl_interp_address(pTHX)
@@ -401,8 +404,8 @@

 void modperl_env_request_tie(pTHX_ request_rec *r)
 {
-    EnvMgObj = (char *)r;
-    EnvMgLen = -1;
+    EnvMgObjSet(r);
+    EnvMgLenSet(-1);

 #ifdef MP_PERL_HV_GMAGICAL_AWARE
     MP_TRACE_e(MP_FUNC, "[%s/0x%lx] tie %%ENV, $r\n\t (%s%s)",
@@ -414,7 +417,7 @@

 void modperl_env_request_untie(pTHX_ request_rec *r)
 {
-    EnvMgObj = NULL;
+    EnvMgObjSet(NULL);

 #ifdef MP_PERL_HV_GMAGICAL_AWARE
     MP_TRACE_e(MP_FUNC, "[%s/0x%lx] untie %%ENV; # from r\n\t (%s%s)",


Let me know if it does fix your problem, and I'll apply it.

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message