RE: [PECL-DEV] apc causing segmentation fault?
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | RE: [PECL-DEV] apc causing segmentation fault? | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-1073@lists.php.net to get a copy of this message | ||
Here is the patch I'll commit soon. You might have a bit of an offset as
my tree is a little bit different.
RCS file: /CVSROOT/apc/apc_main.c,v
retrieving revision 1.10
diff -u -r1.10 apc_main.c
--- apc_main.c 28 Jun 2004 08:59:06 -0000 1.10
+++ apc_main.c 30 Jul 2004 17:06:26 -0000
@@ -276,6 +276,26 @@
/* restore compilation */
zend_compile_file = old_compile_file;
+ while (apc_stack_size(APCG(cache_stack)) > 0) {
+ int i;
+ apc_cache_entry_t* cache_entry = (apc_cache_entry_t*) apc_stack_pop(APCG(cache_stack));
+ if (cache_entry->functions) {
+ for (i = 0; cache_entry->functions[i].function != NULL; i++) {
+ zend_hash_del(EG(function_table),
+ cache_entry->functions[i].name,
+ cache_entry->functions[i].name_len+1);
+ }
+ }
+ if (cache_entry->classes) {
+ for (i = 0; cache_entry->classes[i].class_entry != NULL; i++) {
+ zend_hash_del(EG(class_table),
+ cache_entry->classes[i].name,
+ cache_entry->classes[i].name_len+1);
+ }
+ }
+ apc_cache_free_entry(cache_entry);
+ }
+
/* apc cleanup */
apc_stack_destroy(APCG(cache_stack));
apc_cache_destroy(APCG(cache));
This code is in the apc_module_shutdown() function in apc_main.c and the
problem it fixes is that on a SIGTERM during script execution,
apc_module_shutdown() blows away all allocated memory, but leaves pointers
to this memory on the global function and class tables. When PHP later on
tries to clean those up we get a crash. So in this patch I walk through
all the active cache entries and remove any function and class pointers on
the global lists before freeing the memory.
-Rasmus