com php-src: Fix phpdbg ZTS shutdown with USE_ZEND_ALLOC: sapi/phpdbg/phpdbg.c
| From: | Bob Weinand | Date: | Sun, 13 Nov 2016 11:25:43 +0000 |
| Subject: | com php-src: Fix phpdbg ZTS shutdown with USE_ZEND_ALLOC: sapi/phpdbg/phpdbg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95748@lists.php.net to get a copy of this message | ||
Commit: dbd504eaa9bd6e5055d589753d5e9da5db3d15ab
Author: Bob Weinand <bobwei9@hotmail.com> Sun, 13 Nov 2016 12:25:43 +0100
Parents: 057ae377a06c1209921f66947e9644ecabbb9ccc
Branches: PHP-7.1
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dbd504eaa9bd6e5055d589753d5e9da5db3d15ab
Log:
Fix phpdbg ZTS shutdown with USE_ZEND_ALLOC
Changed paths:
M sapi/phpdbg/phpdbg.c
Diff:
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 3c6101c..f570763 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -1397,6 +1397,10 @@ int main(int argc, char **argv) /* {{{ */
char *read_from_stdin = NULL;
zend_string *backup_phpdbg_compile = NULL;
zend_bool show_help = 0, show_version = 0;
+ void* (*_malloc)(size_t);
+ void (*_free)(void*);
+ void* (*_realloc)(void*, size_t);
+
#ifndef _WIN32
struct sigaction sigio_struct;
@@ -1684,9 +1688,6 @@ phpdbg_main:
EXCEPTION_POINTERS *xp;
__try {
#endif
- void* (*_malloc)(size_t);
- void (*_free)(void*);
- void* (*_realloc)(void*, size_t);
if (show_version || show_help) {
/* It ain't gonna proceed to real execution anyway,
@@ -1767,6 +1768,8 @@ phpdbg_main:
zend_mm_set_custom_handlers(mm_heap, _malloc, _free, _realloc);
}
+ _free = PHPDBG_G(original_free_function);
+
phpdbg_init_list();
@@ -2167,10 +2170,6 @@ phpdbg_out:
sapi_shutdown();
-#ifdef ZTS
- ts_free_id(phpdbg_globals_id);
-#endif
-
if (sapi_name) {
free(sapi_name);
}
@@ -2182,6 +2181,13 @@ free_and_return:
}
#ifdef ZTS
+ /* reset to original handlers - otherwise PHPDBG_G() in phpdbg_watch_efree will be segfaulty (with
e.g. USE_ZEND_ALLOC=0) */
+ if (!use_mm_wrappers) {
+ zend_mm_set_custom_handlers(zend_mm_get_heap(), _malloc, _free, _realloc);
+ }
+
+ ts_free_id(phpdbg_globals_id);
+
tsrm_shutdown();
#endif