Re: regex cacheing segfault
| From: | Zeev Suraski | Date: | Sun, 27 Dec 1998 23:35:44 +0000 |
| Subject: | Re: regex cacheing segfault | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-3082@lists.php.net to get a copy of this message | ||
At 16:21 27/12/98 -0500, Rasmus Lerdorf wrote:
>This new regex cacheing code needs a bit of debugging. It is quite broken
>at the moment. I'll take a look later on tonight, but if Sascha is awake,
>please have a look.
From a first glance, there's the infamous initialization bug in the
implementation. Thou shalt never rely on global or static variable
initialization. I'll add that to the coding standards file.
The reason for this is clear (even though this problem bit us all at one
point or another) - relying on global/static variable initialization means
it works only once, when the program starts up (or the function first being
called). Since PHP in its module mode is a function that is repeatedly
called, this isn't good enough - which is why per-request initialization
functions are available to the modules.
rc right now contains a pointer to an e*()'d memory chunk, but doesn't
clean itself on every request, so after the first request, it points at
invalid memory. The solution would be moving the NULL initlization to the
regex per-request startup function, and it'd be nice to add destruction
code to the regex per-request shutdown function. Also, rc should really be
made static, we don't want everybody to have this variable in their namespace.
Zeev
--
Zeev Suraski <zeev@zend.com>
For a PGP public key, finger bourbon@netvision.net.il
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net