com php-src: Temorary fix for phpdbg segfault while use zend_mm_set_custom_handlers: Zend/zend_alloc.c sapi/phpdbg/phpdbg.c

From: Date: Mon, 09 Mar 2015 03:19:05 +0000
Subject: com php-src: Temorary fix for phpdbg segfault while use zend_mm_set_custom_handlers: Zend/zend_alloc.c sapi/phpdbg/phpdbg.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85372@lists.php.net to get a copy of this message
Commit: 96f7a33df6e72dc855b82140ab10ddeaaf19b20c Author: Xinchen Hui <laruence@php.net> Mon, 9 Mar 2015 11:19:05 +0800 Parents: 69d183dd1926c4f1b35f9303e6960732f71e29de Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=96f7a33df6e72dc855b82140ab10ddeaaf19b20c Log: Temorary fix for phpdbg segfault while use zend_mm_set_custom_handlers Changed paths: M Zend/zend_alloc.c M sapi/phpdbg/phpdbg.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index b066eb0..6701ca4 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1950,6 +1950,9 @@ void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent) #if ZEND_MM_CUSTOM if (heap->use_custom_heap) { + if (full) { + heap->_free(heap); + } return; } #endif diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 74bf84a..a12811f 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -983,7 +983,14 @@ void *phpdbg_malloc_wrapper(size_t size) /* {{{ */ void phpdbg_free_wrapper(void *p) /* {{{ */ { - zend_mm_free(phpdbg_mm_get_heap(), p); + zend_mm_heap *heap = phpdbg_mm_get_heap(); + if (UNEXPECTED(heap == p)) { + /* TODO: heap maybe allocated by mmap(zend_mm_init) or malloc(USE_ZEND_ALLOC=0) + * let's prevent it from segfault for now + */ + } else { + zend_mm_free(heap, p); + } } /* }}} */ void *phpdbg_realloc_wrapper(void *ptr, size_t size) /* {{{ */

« previous php.cvs (#85372) next »