You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by go...@apache.org on 2005/12/16 22:20:26 UTC
svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Author: gozer
Date: Fri Dec 16 13:20:23 2005
New Revision: 357236
URL: http://svn.apache.org/viewcvs?rev=357236&view=rev
Log:
"local %ENV;" caused Segmentation fault in modperl_env_request_tie()
Reported-By: Peter Walsham <pe...@axomic.com>
Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
Modified:
perl/modperl/trunk/src/modules/perl/modperl_env.c
Modified: perl/modperl/trunk/src/modules/perl/modperl_env.c
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_env.c?rev=357236&r1=357235&r2=357236&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_env.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_env.c Fri Dec 16 13:20:23 2005
@@ -15,8 +15,13 @@
#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 = (char *)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 +406,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 +419,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)",
Re: svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
[...]
>>>Which reminds me, it would be nice to have a bug/ test categorie for
>>>such gems
>>>that don't fit very nicely anywhere else.
>>
>>This test fits perfectly into the main test suite. But yes, we need to
>>have a new directory for other tests. Long ago I've suggested t_extra.
>
>
> Wasn't t_extra for the kind of developer's tests what would not be executed
> unless we were building in maintainer-mode ?
No, it was for test that can't fit into the main test suite. e.g. test
that relay on a virgin configuration (I've posted at least 2 sub A-T based
tarballs recently, I could only reproduce the bug with a standalone config)
> I was more thinking of a category of tests specifically to nail down known
> bugs.
correct.
--
_____________________________________________________________
Stas Bekman mailto:stas@stason.org http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Stas Bekman wrote:
> Philippe M. Chiasson wrote:
>> Stas Bekman wrote:
>>> gozer@apache.org wrote:
>>>> Author: gozer
>>>> Date: Fri Dec 16 13:20:23 2005
>>>> New Revision: 357236
>>>>
>>>> URL: http://svn.apache.org/viewcvs?rev=357236&view=rev
>>>> Log:
>>>> "local %ENV;" caused Segmentation fault in modperl_env_request_tie()
>>>>
>>>> Reported-By: Peter Walsham <pe...@axomic.com>
>>>> Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
>>>
>>> a bug fix w/o adding a test?
>>
>> Well, the test would cause a segfault, so figured it wasn't such a
>> good idea
>> to add it.
>
> I'm not following you Philippe, you've fixed it. Isn't that how all
> tests are written? You first write a test, you then fix it and then you
> commit the test and the fix, no?
Yup, you are correct. This reasoning was caused by : gozer.brain->off();
>> But now that the fix is in, I guess I could make a test case to make
>> sure it now works. Good point Stas ;-)
>>
>> Expect test case soon.
>
> gozer++
>
>> Which reminds me, it would be nice to have a bug/ test categorie for
>> such gems
>> that don't fit very nicely anywhere else.
>
> This test fits perfectly into the main test suite. But yes, we need to
> have a new directory for other tests. Long ago I've suggested t_extra.
Wasn't t_extra for the kind of developer's tests what would not be executed
unless we were building in maintainer-mode ?
I was more thinking of a category of tests specifically to nail down known
bugs.
--------------------------------------------------------------------------------
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
Re: svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> Stas Bekman wrote:
>
>>gozer@apache.org wrote:
>>
>>
>>>Author: gozer
>>>Date: Fri Dec 16 13:20:23 2005
>>>New Revision: 357236
>>>
>>>URL: http://svn.apache.org/viewcvs?rev=357236&view=rev
>>>Log:
>>>"local %ENV;" caused Segmentation fault in modperl_env_request_tie()
>>>
>>>Reported-By: Peter Walsham <pe...@axomic.com>
>>>Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
>>
>>a bug fix w/o adding a test?
>
>
> Well, the test would cause a segfault, so figured it wasn't such a good idea
> to add it.
I'm not following you Philippe, you've fixed it. Isn't that how all tests
are written? You first write a test, you then fix it and then you commit
the test and the fix, no?
> But now that the fix is in, I guess I could make a test case to make
> sure it now works. Good point Stas ;-)
>
> Expect test case soon.
gozer++
> Which reminds me, it would be nice to have a bug/ test categorie for such gems
> that don't fit very nicely anywhere else.
This test fits perfectly into the main test suite. But yes, we need to
have a new directory for other tests. Long ago I've suggested t_extra.
--
_____________________________________________________________
Stas Bekman mailto:stas@stason.org http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Philippe M. Chiasson wrote:
> Stas Bekman wrote:
>
>>gozer@apache.org wrote:
>>
>>
>>>Author: gozer
>>>Date: Fri Dec 16 13:20:23 2005
>>>New Revision: 357236
>>>
>>>URL: http://svn.apache.org/viewcvs?rev=357236&view=rev
>>>Log:
>>>"local %ENV;" caused Segmentation fault in modperl_env_request_tie()
>>>
>>>Reported-By: Peter Walsham <pe...@axomic.com>
>>>Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
>>
>>a bug fix w/o adding a test?
>
>
> Well, the test would cause a segfault, so figured it wasn't such a good idea
> to add it. But now that the fix is in, I guess I could make a test case to make
> sure it now works. Good point Stas ;-)
>
> Expect test case soon.
Commited r357282 with a simplistic test that would cause that segfault if the
bug is ever re-introduced.
> Which reminds me, it would be nice to have a bug/ test categorie for such gems
> that don't fit very nicely anywhere else.
How's t/bugs/ sound for bits like this one ?
--------------------------------------------------------------------------------
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
Re: svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Stas Bekman wrote:
> gozer@apache.org wrote:
>
>> Author: gozer
>> Date: Fri Dec 16 13:20:23 2005
>> New Revision: 357236
>>
>> URL: http://svn.apache.org/viewcvs?rev=357236&view=rev
>> Log:
>> "local %ENV;" caused Segmentation fault in modperl_env_request_tie()
>>
>> Reported-By: Peter Walsham <pe...@axomic.com>
>> Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
>
> a bug fix w/o adding a test?
Well, the test would cause a segfault, so figured it wasn't such a good idea
to add it. But now that the fix is in, I guess I could make a test case to make
sure it now works. Good point Stas ;-)
Expect test case soon.
Which reminds me, it would be nice to have a bug/ test categorie for such gems
that don't fit very nicely anywhere else.
--------------------------------------------------------------------------------
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
Re: svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Posted by Stas Bekman <st...@stason.org>.
gozer@apache.org wrote:
> Author: gozer
> Date: Fri Dec 16 13:20:23 2005
> New Revision: 357236
>
> URL: http://svn.apache.org/viewcvs?rev=357236&view=rev
> Log:
> "local %ENV;" caused Segmentation fault in modperl_env_request_tie()
>
> Reported-By: Peter Walsham <pe...@axomic.com>
> Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
a bug fix w/o adding a test?
> Modified:
> perl/modperl/trunk/src/modules/perl/modperl_env.c
>
> Modified: perl/modperl/trunk/src/modules/perl/modperl_env.c
> URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_env.c?rev=357236&r1=357235&r2=357236&view=diff
> ==============================================================================
> --- perl/modperl/trunk/src/modules/perl/modperl_env.c (original)
> +++ perl/modperl/trunk/src/modules/perl/modperl_env.c Fri Dec 16 13:20:23 2005
> @@ -15,8 +15,13 @@
>
> #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 = (char *)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 +406,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 +419,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)",
>
--
_____________________________________________________________
Stas Bekman mailto:stas@stason.org http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org