Re: pemalloc in PHP_MINIT_FUNCTION segfaults on win (but not on linux)
| From: | Antony Dovgal | Date: | Tue, 13 Mar 2007 20:47:20 +0000 |
| Subject: | Re: pemalloc in PHP_MINIT_FUNCTION segfaults on win (but not on linux) | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-4623@lists.php.net to get a copy of this message | ||
On 03/13/2007 11:26 PM, Holger Blasum wrote:
Hello pecl-dev, executive summary: in php-5.2.0 (or 5.0.0), is it ok to do a pemalloc in the PHP_MINIT_FUNCTION?pemalloc(.., 1) == malloc() so it is safe and there is no other way (all the memory allocated with emalloc() is automatically freed on request shutdown).
If not, what is the appropriate (minimalist) way to provide memory that is going to be shared globally among all threads/clients?Use true global variables with mutexes?
slightly more verbose explanation: this is my PHP_MINIT_FUNCTION
PHP_MINIT_FUNCTION(stack) {
StackContext(s) = (STACK *)pemalloc(sizeof(STACK),1);
return SUCCESS;
} to have a globally shared stack. (To be shared among different threads/clients.)
Much more detail (including full source of the toy 'stack' example) at http://www.blasum.net/holger/journal/20070312/
(valgrinding it on linux gves me 'ERROR SUMMARY: 0 errors from 0
contexts (suppressed: 29 from 2)', for the suppressed ones i have 25 in libc5 and 4 in dl_relocate_object, so apparently not php-related)
Many thanks in advance for any help (e.g.: is this generally the 'right way' of doing this? (I admit that I wanted to avoid resources
because they seem thread-specific.) Did I make a subtle error or is it a win-specific thing?... )
--
Wbr,
Antony Dovgal