diff options
-rw-r--r-- | Zend/zend_alloc.c | 1 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg.c | 36 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_cmd.c | 14 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_prompt.c | 8 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_sigsafe.c | 4 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_sigsafe.h | 2 |
6 files changed, 39 insertions, 26 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 493cf1f728..16838e04da 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2765,6 +2765,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void #endif heap->storage = &tmp_storage; heap->huge_list = NULL; + memset(heap->free_slot, 0, sizeof(heap->free_slot)); storage = _zend_mm_alloc(heap, sizeof(zend_mm_storage) + data_size ZEND_FILE_LINE_CC ZEND_FILE_LINE_CC); if (!storage) { handlers->chunk_free(&tmp_storage, chunk, ZEND_MM_CHUNK_SIZE); diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 831d4fc472..4c5dfdea22 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -220,7 +220,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_llist_destroy(&PHPDBG_G(watchlist_mem)); if (PHPDBG_G(buffer)) { - efree(PHPDBG_G(buffer)); + free(PHPDBG_G(buffer)); PHPDBG_G(buffer) = NULL; } @@ -1085,17 +1085,21 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ } } else { /* set signalled only when not interactive */ - if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { - if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { - char mem[PHPDBG_SIGSAFE_MEM_SIZE + 1]; - - phpdbg_set_sigsafe_mem(mem); - zend_try { - phpdbg_force_interruption(); - } zend_end_try() - phpdbg_clear_sigsafe_mem(); - return; + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { + char mem[PHPDBG_SIGSAFE_MEM_SIZE + 1]; + + phpdbg_set_sigsafe_mem(mem); + zend_try { + phpdbg_force_interruption(); + } zend_end_try() + phpdbg_clear_sigsafe_mem(); + + PHPDBG_G(flags) &= ~PHPDBG_IS_SIGNALED; + + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + zend_bailout(); } + } else { PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; } } @@ -1182,9 +1186,13 @@ void phpdbg_sigio_handler(int sig, siginfo_t *info, void *context) /* {{{ */ phpdbg_force_interruption(); } zend_end_try(); phpdbg_clear_sigsafe_mem(); - break; - } - if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + + PHPDBG_G(flags) &= ~PHPDBG_IS_SIGNALED; + + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + zend_bailout(); + } + } else if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; } break; diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index a50b340e7d..ed4cf3b6d6 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -768,16 +768,14 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */ if (buffer && strlen(buffer)) { if (PHPDBG_G(buffer)) { - efree(PHPDBG_G(buffer)); + free(PHPDBG_G(buffer)); } - PHPDBG_G(buffer) = estrdup(buffer); - } else { - if (PHPDBG_G(buffer)) { - if (buffer) { - efree(buffer); - } - buffer = estrdup(PHPDBG_G(buffer)); + PHPDBG_G(buffer) = strdup(buffer); + } else if (PHPDBG_G(buffer)) { + if (buffer) { + efree(buffer); } + buffer = estrdup(PHPDBG_G(buffer)); } return buffer; diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 2001129ec8..5d5ed2822a 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1628,7 +1628,13 @@ void phpdbg_force_interruption(void) /* {{{ */ { if (data) { if (data->func) { - phpdbg_notice("hardinterrupt", "opline=\"%p\" num=\"%lu\" file=\"%s\" line=\"%u\"", "Current opline: %p (op #%lu) in %s:%u", data->opline, (data->opline - data->func->op_array.opcodes) / sizeof(data->opline), data->func->op_array.filename, data->opline->lineno); + if (ZEND_USER_CODE(data->func->type)) { + phpdbg_notice("hardinterrupt", "opline=\"%p\" num=\"%lu\" file=\"%s\" line=\"%u\"", "Current opline: %p (op #%lu) in %s:%u", data->opline, (data->opline - data->func->op_array.opcodes) / sizeof(data->opline), data->func->op_array.filename, data->opline->lineno); + } else if (data->func->internal_function.function_name) { + phpdbg_notice("hardinterrupt", "func=\"%s\"", "Current opline: in internal function %s", data->func->internal_function.function_name->val); + } else { + phpdbg_notice("hardinterrupt", "", "Current opline: executing internal code"); + } } else { phpdbg_notice("hardinterrupt", "opline=\"%p\"", "Current opline: %p (op_array information unavailable)", data->opline); } diff --git a/sapi/phpdbg/phpdbg_sigsafe.c b/sapi/phpdbg/phpdbg_sigsafe.c index 82cb7aba01..54af08ec5b 100644 --- a/sapi/phpdbg/phpdbg_sigsafe.c +++ b/sapi/phpdbg/phpdbg_sigsafe.c @@ -8,9 +8,9 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); static void* zend_mm_mem_alloc(zend_mm_storage *storage, size_t size, size_t alignment) { - if (EXPECTED(size == PHPDBG_SIGSAFE_MEM_SIZE && !PHPDBG_G(sigsafe_mem).allocated)) { + if (EXPECTED(size <= PHPDBG_SIGSAFE_MEM_SIZE && !PHPDBG_G(sigsafe_mem).allocated)) { PHPDBG_G(sigsafe_mem).allocated = 1; - return PHPDBG_G(sigsafe_mem).mem; + return (void *) (((size_t) PHPDBG_G(sigsafe_mem).mem & ~(alignment - 1)) + alignment); } quiet_write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Tried to allocate more than " EXP_STR(PHPDBG_SIGSAFE_MEM_SIZE) " bytes from stack memory in signal handler ... bailing out of signal handler\n")); diff --git a/sapi/phpdbg/phpdbg_sigsafe.h b/sapi/phpdbg/phpdbg_sigsafe.h index e27b12c76c..ab689a38d8 100644 --- a/sapi/phpdbg/phpdbg_sigsafe.h +++ b/sapi/phpdbg/phpdbg_sigsafe.h @@ -1,7 +1,7 @@ #ifndef PHPDBG_SIGSAFE_H #define PHPDBG_SIGSAFE_H -#define PHPDBG_SIGSAFE_MEM_SIZE ZEND_MM_CHUNK_SIZE // (1 << 20) +#define PHPDBG_SIGSAFE_MEM_SIZE (ZEND_MM_CHUNK_SIZE * 2) #include "zend.h" |