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

Re: 5.8.2-RC1 and mp2

Thread Previous | Thread Next
From:
Stas Bekman
Date:
November 2, 2003 01:00
Subject:
Re: 5.8.2-RC1 and mp2
Message ID:
3FA4C793.9030200@stason.org
Nicholas Clark wrote:
> On Thu, Oct 30, 2003 at 01:37:27AM -0800, Stas Bekman wrote:
> 
> 
>>It calls PERL_HASH() to precache hash values. The problem is that we have 
>>to use that function, because we pre-hash the GVs before perl is even 
>>started.
>>
>>It calls:
>>
>>  HE *he = hv_fetch_he(stash, mgv->name, mgv->len, mgv->hash);
>>
>>to get the HE, and then the corresponding GV.
>>
>>See src/modules/perl/modperl_mgv.c
>>http://cvs.apache.org/viewcvs.cgi/*checkout*/modperl-2.0/src/modules/perl/modperl_mgv.c?rev=HEAD&content-type=text/plain
>>
>>find hv_fetch_he.
> 
> 
>   "You keep using that word. I do not think it means what you think it means."
>   :-)
> 
> 
> http://cvs.apache.org/viewcvs.cgi/*checkout*/modperl-2.0/src/modules/perl/modperl_util.h?rev=HEAD&content-type=text/plain
> 
> #define hv_fetch_he(hv,k,l,h) \
>     modperl_perl_hv_fetch_he(aTHX_ hv, k, l, h)

Hmm, that's right. ETOOMANYMACROS

> I'm not sure how to make modperl run the test you sent to p5p so I've not
> been able to test it.
> (I can't edit httpd.conf to add it as the auto-generation blows it away,
>  I can't work out where httpd.conf is auto-generated,
>  and I can't spot how to re-run mod_perl from the shell prompt)

apply the patch and just run 'make test' and it'll automatically configure 
that new test. Alternatively, running 't/TEST -conf' does the configuration as 
well.

> However,
> 
> export PERL_HASH_SEED=123456789
> 
> seems to make the the server fail to start as is. With the appended patch
> everything works. You'll need to sync maint to (at least) 21608:
> 
> @@ -89,7 +89,7 @@
>    (hash) = (hash_PeRlHaSh + (hash_PeRlHaSh << 15)); \
>      } STMT_END
>  
> -#ifdef PERL_IN_HV_C
> +#if defined (PERL_IN_HV_C) || defined (MOD_PERL)
>  #define PERL_HASH_INTERNAL(hash,str,len) \
>       STMT_START { \
>    register const char *s_PeRlHaSh_tmp = str; \

I'm not sure it's a good idea to make perl's code depend on MOD_PERL define. 
What I miss to understand is the mess with PL_hash_seed and PL_new_hash_seed. 
Currently perl is broken, because if you specify PERL_HASH_SEED=123456789 env 
var, it gets assigned to PL_new_hash_seed. PERL_HASH uses PL_hash_seed, so it 
totally ignores user defined hash seed. That's why I was successful at using 
Scott's attack input no matter what the PERL_HASH_SEED was.

Why do we need two variables? If PL_hash_seed is there only for binary 
compatibility, why not have the two point to the same thing? I've 
s/PL_hash_seed/PL_new_hash_seed/ in hv.[ch] and I've got everything working as 
well.

> Also 21605 gives Internals::HvREHASH which can be used to check the
> rehashing flag, and a t/op/hash.t which uses it.

Thank you very much for that one! This and Internals::hash_seed() are very 
useful for this test.

> (See http://public.activestate.com/cgi-bin/perlbrowse?recent=1
> for what's been changed recently)
> 
> I hope that this (with the per-thread initialisation of PL_new_hash_seed) 
> is the fix. I'm going to be out for about the next 24 hours.
> 
> Nicholas Clark
> 
> --- src/modules/perl/modperl_util.c.orig	2003-10-10 05:17:22.000000000 +0100
> +++ src/modules/perl/modperl_util.c	2003-11-01 16:18:10.000000000 +0000
> @@ -473,6 +473,11 @@ HE *modperl_perl_hv_fetch_he(pTHX_ HV *h
>          return 0;
>      }
>  
> +#ifdef HvREHASH
> +    if (HvREHASH(hv)) {
> +	PERL_HASH_INTERNAL(hash, key, klen);
> +    } else
> +#endif
>      if (!hash) {
>  	PERL_HASH(hash, key, klen);
>      }

Cool. For some reason with the other patches I've applied earlier I didn't 
need this fix. Maybe I've missed something. Will check later again.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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