From 1d3a53a18d87a9fca3cb1fc857201dd2dfc8f9d0 Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Wed, 25 Dec 2013 18:50:25 +0000 Subject: [PATCH 01/16] upstream merge --- phpdbg_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 86c17a71be..7b2000da0e 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -290,8 +290,9 @@ PHPDBG_API int phpdbg_rlog(FILE *fp, const char *fmt, ...) { /* {{{ */ if (gettimeofday(&tp, NULL) == SUCCESS) { char friendly[100]; char *format = NULL, *buffer = NULL; + const time_t tt = tp.tv_sec; - strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tp.tv_sec)); + strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tt)); asprintf( &buffer, friendly, tp.tv_usec/1000); asprintf( From 2712d7e2248ab91015502d648c9c65d8e5627e69 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Fri, 27 Dec 2013 18:10:58 +0000 Subject: [PATCH 02/16] update version --- phpdbg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index d025294f1f..481a1815db 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1038,11 +1038,10 @@ phpdbg_main: sapi_startup(phpdbg); phpdbg->startup(phpdbg); printf( - "phpdbg %s (built: %s %s)\nCopyright (c) 2013 %s\nPHP %s, Copyright (c) 1997-2013 The PHP Group\n%s", + "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2013 The PHP Group\n%s", PHPDBG_VERSION, __DATE__, __TIME__, - PHPDBG_AUTHORS, PHP_VERSION, get_zend_version() ); From 7d51e47eda97a6570ebebfc8e0d512e7575443a6 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 12 Jan 2014 16:48:10 +0000 Subject: [PATCH 03/16] work on #46 (handle quit local consoles gracefully) --- phpdbg.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 481a1815db..1ada36c7a1 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1243,18 +1243,25 @@ phpdbg_interact: #ifndef _WIN32 /* remote client disconnected */ if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { - - /* renegociate connections */ - phpdbg_open_sockets( - address, listen, &server, &socket, streams); - /* set streams */ - if (streams[0] && streams[1]) { - PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + /* renegociate connections */ + phpdbg_open_sockets( + address, listen, &server, &socket, streams); + + /* set streams */ + if (streams[0] && streams[1]) { + PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; + } + + /* this must be forced */ + CG(unclean_shutdown) = 0; + } else { + /* local client quit console */ + CG(unclean_shutdown) = 0; + + goto phpdbg_out; } - - /* this must be forced */ - CG(unclean_shutdown) = 0; } #endif if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { From 333264fdb718f337fb19d208e3d41aeef31f2ca1 Mon Sep 17 00:00:00 2001 From: cyanogenmod Date: Mon, 13 Jan 2014 08:11:09 +0000 Subject: [PATCH 04/16] fix #46 ignore EOF --- phpdbg.c | 10 ++++------ phpdbg_cmd.c | 35 +++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 1ada36c7a1..c631d8f3c3 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1257,10 +1257,8 @@ phpdbg_interact: /* this must be forced */ CG(unclean_shutdown) = 0; } else { - /* local client quit console */ - CG(unclean_shutdown) = 0; - - goto phpdbg_out; + /* local consoles cannot disconnect, ignore EOF */ + PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; } } #endif @@ -1275,7 +1273,7 @@ phpdbg_interact: phpdbg_out: #ifndef _WIN32 - if (PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED) { + if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; goto phpdbg_interact; } @@ -1324,7 +1322,7 @@ phpdbg_out: if (cleaning || remote) { goto phpdbg_main; } - + #ifdef ZTS /* bugggy */ /* tsrm_shutdown(); */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 9f052d6f6f..501d0b8bf6 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -467,32 +467,43 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ } if (buffered == NULL) { -#ifndef HAVE_LIBREADLINE - char buf[PHPDBG_MAX_CMD]; - if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) || - !fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { - /* the user has gone away */ - phpdbg_error("Failed to read console!"); +disconnect: + if (0) { PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); zend_bailout(); return NULL; } +#ifndef HAVE_LIBREADLINE + char buf[PHPDBG_MAX_CMD]; + if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_CC))) { + goto disconnect; + } + } + + /* note: EOF is ignored */ +readline: + if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { + /* the user has gone away */ + if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + goto disconnect; + } else goto readline; + } + cmd = buf; #else + /* note: EOF makes readline write prompt again in local console mode */ +readline: if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { char buf[PHPDBG_MAX_CMD]; if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { cmd = buf; - } else cmd = NULL; + } else goto disconnect; } else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); if (!cmd) { - /* the user has gone away */ - phpdbg_error("Failed to read console!"); - PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); - zend_bailout(); - return NULL; + goto readline; } if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { From 9add0e9f5ce19e9e19a0ca341cbd92c74b35bfcc Mon Sep 17 00:00:00 2001 From: krakjoe Date: Mon, 13 Jan 2014 08:12:49 +0000 Subject: [PATCH 05/16] Revert "fix #46 ignore EOF" This reverts commit 333264fdb718f337fb19d208e3d41aeef31f2ca1. --- phpdbg.c | 10 ++++++---- phpdbg_cmd.c | 35 ++++++++++++----------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index c631d8f3c3..1ada36c7a1 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1257,8 +1257,10 @@ phpdbg_interact: /* this must be forced */ CG(unclean_shutdown) = 0; } else { - /* local consoles cannot disconnect, ignore EOF */ - PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; + /* local client quit console */ + CG(unclean_shutdown) = 0; + + goto phpdbg_out; } } #endif @@ -1273,7 +1275,7 @@ phpdbg_interact: phpdbg_out: #ifndef _WIN32 - if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { + if (PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED) { PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; goto phpdbg_interact; } @@ -1322,7 +1324,7 @@ phpdbg_out: if (cleaning || remote) { goto phpdbg_main; } - + #ifdef ZTS /* bugggy */ /* tsrm_shutdown(); */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 501d0b8bf6..9f052d6f6f 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -467,43 +467,32 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ } if (buffered == NULL) { -disconnect: - if (0) { +#ifndef HAVE_LIBREADLINE + char buf[PHPDBG_MAX_CMD]; + if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) || + !fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { + /* the user has gone away */ + phpdbg_error("Failed to read console!"); PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); zend_bailout(); return NULL; } -#ifndef HAVE_LIBREADLINE - char buf[PHPDBG_MAX_CMD]; - if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { - if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_CC))) { - goto disconnect; - } - } - - /* note: EOF is ignored */ -readline: - if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { - /* the user has gone away */ - if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { - goto disconnect; - } else goto readline; - } - cmd = buf; #else - /* note: EOF makes readline write prompt again in local console mode */ -readline: if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { char buf[PHPDBG_MAX_CMD]; if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { cmd = buf; - } else goto disconnect; + } else cmd = NULL; } else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); if (!cmd) { - goto readline; + /* the user has gone away */ + phpdbg_error("Failed to read console!"); + PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); + zend_bailout(); + return NULL; } if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { From 1ba3ff157e430659565e22c0f1291417306d44d1 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Mon, 13 Jan 2014 08:14:04 +0000 Subject: [PATCH 06/16] fix #46 ignore EOF --- phpdbg.c | 10 ++++------ phpdbg_cmd.c | 35 +++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 1ada36c7a1..c631d8f3c3 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1257,10 +1257,8 @@ phpdbg_interact: /* this must be forced */ CG(unclean_shutdown) = 0; } else { - /* local client quit console */ - CG(unclean_shutdown) = 0; - - goto phpdbg_out; + /* local consoles cannot disconnect, ignore EOF */ + PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; } } #endif @@ -1275,7 +1273,7 @@ phpdbg_interact: phpdbg_out: #ifndef _WIN32 - if (PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED) { + if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; goto phpdbg_interact; } @@ -1324,7 +1322,7 @@ phpdbg_out: if (cleaning || remote) { goto phpdbg_main; } - + #ifdef ZTS /* bugggy */ /* tsrm_shutdown(); */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 9f052d6f6f..501d0b8bf6 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -467,32 +467,43 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ } if (buffered == NULL) { -#ifndef HAVE_LIBREADLINE - char buf[PHPDBG_MAX_CMD]; - if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) || - !fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { - /* the user has gone away */ - phpdbg_error("Failed to read console!"); +disconnect: + if (0) { PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); zend_bailout(); return NULL; } +#ifndef HAVE_LIBREADLINE + char buf[PHPDBG_MAX_CMD]; + if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_CC))) { + goto disconnect; + } + } + + /* note: EOF is ignored */ +readline: + if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { + /* the user has gone away */ + if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { + goto disconnect; + } else goto readline; + } + cmd = buf; #else + /* note: EOF makes readline write prompt again in local console mode */ +readline: if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { char buf[PHPDBG_MAX_CMD]; if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { cmd = buf; - } else cmd = NULL; + } else goto disconnect; } else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); if (!cmd) { - /* the user has gone away */ - phpdbg_error("Failed to read console!"); - PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); - zend_bailout(); - return NULL; + goto readline; } if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { From c645e5043edadc986a24eac2bcc64842da5f0d98 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Mon, 13 Jan 2014 08:19:37 +0000 Subject: [PATCH 07/16] patch version --- phpdbg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg.h b/phpdbg.h index 3a3da7636a..7844772533 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -149,7 +149,7 @@ #define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */ #define PHPDBG_URL "http://phpdbg.com" #define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues" -#define PHPDBG_VERSION "0.3.0" +#define PHPDBG_VERSION "0.3.1" #define PHPDBG_INIT_FILENAME ".phpdbginit" /* }}} */ From 231a1c401bf91aa154585cbc465a6902e90bddb4 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Mon, 13 Jan 2014 20:16:50 +0000 Subject: [PATCH 08/16] issues raised in #46, don't quit on CTRL+C if not executing --- phpdbg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index c631d8f3c3..1e69e4bdbf 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -654,8 +654,11 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; } } else { - PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; - zend_bailout(); + /* we quit remote consoles on recv SIGINT */ + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + zend_bailout(); + } } } /* }}} */ @@ -1271,6 +1274,9 @@ phpdbg_interact: /* this must be forced */ CG(unclean_shutdown) = 0; + /* this is just helpful */ + PG(report_memleaks) = 0; + phpdbg_out: #ifndef _WIN32 if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { From 837bd24dea5c32dc186a1fe484c2c276e97e92e1 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Thu, 16 Jan 2014 20:10:30 +0000 Subject: [PATCH 09/16] fix #50 --- phpdbg_opcode.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c index 025d57a08d..8119158469 100644 --- a/phpdbg_opcode.c +++ b/phpdbg_opcode.c @@ -52,13 +52,15 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, zend_uint case IS_VAR: case IS_TMP_VAR: { zend_ulong id = 0, *pid = NULL; - if (zend_hash_index_find(vars, (zend_ulong) ops->vars - op->var, (void**) &pid) != SUCCESS) { - id = zend_hash_num_elements(vars); - zend_hash_index_update( - vars, (zend_ulong) ops->vars - op->var, - (void**) &id, - sizeof(zend_ulong), NULL); - } else id = *pid; + if (vars != NULL) { + if (zend_hash_index_find(vars, (zend_ulong) ops->vars - op->var, (void**) &pid) != SUCCESS) { + id = zend_hash_num_elements(vars); + zend_hash_index_update( + vars, (zend_ulong) ops->vars - op->var, + (void**) &id, + sizeof(zend_ulong), NULL); + } else id = *pid; + } asprintf(&decode, "@%lu", id); } break; From 03386d178626e3ce1ff9afcf53fa7fbb4f8a2b87 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 17 Jan 2014 12:18:16 +0100 Subject: [PATCH 10/16] Clarify always_populate_raw_post_data situation in 5.6 --- NEWS | 7 ++++--- UPGRADING | 14 +++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 735d858ca8..340b3e56ac 100644 --- a/NEWS +++ b/NEWS @@ -16,9 +16,10 @@ PHP NEWS (Gustavo) . Uploads equal or greater than 2GB in size are now accepted. (Ralf Lang, Mike) - . Reduced POST data memory usage by 200-300%. Removed INI setting - always_populate_raw_post_data and the $HTTP_RAW_POST_DATA global - variable. (Mike) + . Reduced POST data memory usage by 200-300%. Changed INI setting + always_populate_raw_post_data to throw a deprecation warning when enabling + and to accept -1 for never populating the $HTTP_RAW_POST_DATA global + variable, which will be the default in future PHP versions. (Mike) . Implemented dedicated syntax for variadic functions (RFC: https://wiki.php.net/rfc/variadics). (Nikita) . Fixed bug #50333 Improving multi-threaded scalability by using diff --git a/UPGRADING b/UPGRADING index f2be0a3ea8..a2e92616ce 100755 --- a/UPGRADING +++ b/UPGRADING @@ -20,16 +20,6 @@ PHP X.Y UPGRADE NOTES 1. Backward Incompatible Changes ======================================== -- Core: - Removed $HTTP_RAW_POST_DATA global variable. Restore backwards compatibility - by: - - - JSON: json_decode() no longer accepts non-lowercase variants of lone JSON true, false or null values. For example, True or FALSE will now cause json_decode to @@ -148,7 +138,9 @@ PHP X.Y UPGRADE NOTES ======================================== - Core: - Removed always_populate_raw_post_data. + Changed always_populate_raw_post_data to throw a deprecation warning when + enabled and to recognize ohe value -1 for never populating the global + $HTTP_RAW_POST_DATA variable, which will be default in future PHP versions. ======================================== 11. Other Changes From 43a8f4f81439455d22471822bfa5f61708a2dc17 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Fri, 17 Jan 2014 20:28:49 +0800 Subject: [PATCH 11/16] Add a couple of missing items to UPGRADING. Usual grumble about please ensuring UPGRADING gets updated goes here. :) --- UPGRADING | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UPGRADING b/UPGRADING index a2e92616ce..8f83b51101 100755 --- a/UPGRADING +++ b/UPGRADING @@ -38,6 +38,9 @@ PHP X.Y UPGRADE NOTES - Added dedicated syntax for variadic functions. (https://wiki.php.net/rfc/variadics) +- Added support for argument unpacking to complement the variadic syntax. + (https://wiki.php.net/rfc/argument_unpacking) + - The php://input stream is now re-usable and can be used concurrently with enable_post_data_reading=0. @@ -48,6 +51,9 @@ PHP X.Y UPGRADE NOTES - Added openssl crypto method stream context option. +- Added use function and use const. + (https://wiki.php.net/rfc/use_function) + ======================================== 2. Changes in SAPI modules ======================================== From 54fa2883f0be3f4ac3e9faab77434e1833bbae5c Mon Sep 17 00:00:00 2001 From: krakjoe Date: Fri, 17 Jan 2014 21:08:35 +0000 Subject: [PATCH 12/16] remove goto from zend_try/zend_end_try/zend_catch blocks --- phpdbg.c | 20 ++++++++------------ phpdbg_prompt.c | 20 +++++++++++--------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 1e69e4bdbf..8225a90125 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1202,17 +1202,17 @@ phpdbg_main: } zend_end_try(); /* initialize from file */ + PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; zend_try { - PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC); phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC); - PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; - } zend_catch { - PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { - goto phpdbg_out; - } } zend_end_try(); + PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; + + /* quit if init says so */ + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + goto phpdbg_out; + } /* step from here, not through init */ if (step) { @@ -1239,7 +1239,6 @@ phpdbg_interact: phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC); fclose(bp_tmp_fp); cleaning = 1; - goto phpdbg_out; } else { cleaning = 0; } @@ -1265,11 +1264,8 @@ phpdbg_interact: } } #endif - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { - goto phpdbg_out; - } } zend_end_try(); - } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + } while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); /* this must be forced */ CG(unclean_shutdown) = 0; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index f2f482b7ec..6d199b0673 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -551,7 +551,8 @@ PHPDBG_COMMAND(run) /* {{{ */ zend_op **orig_opline = EG(opline_ptr); zend_op_array *orig_op_array = EG(active_op_array); zval **orig_retval_ptr = EG(return_value_ptr_ptr); - + zend_bool restore = 1; + if (!PHPDBG_G(ops)) { if (phpdbg_compile(TSRMLS_C) == FAILURE) { phpdbg_error("Failed to compile %s, cannot run", PHPDBG_G(exec)); @@ -586,18 +587,19 @@ PHPDBG_COMMAND(run) /* {{{ */ if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { phpdbg_error("Caught exit/error from VM"); - goto out; + restore = 0; } } zend_end_try(); - if (EG(exception)) { - phpdbg_handle_exception(TSRMLS_C); + if (restore) { + if (EG(exception)) { + phpdbg_handle_exception(TSRMLS_C); + } + + EG(active_op_array) = orig_op_array; + EG(opline_ptr) = orig_opline; + EG(return_value_ptr_ptr) = orig_retval_ptr; } - - EG(active_op_array) = orig_op_array; - EG(opline_ptr) = orig_opline; - EG(return_value_ptr_ptr) = orig_retval_ptr; - } else { phpdbg_error("Nothing to execute!"); } From 18f31d474ee384509e4e06d5441c38be747df383 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Fri, 17 Jan 2014 21:15:03 +0000 Subject: [PATCH 13/16] ... --- phpdbg.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 8225a90125..a2e1e75b23 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1242,25 +1242,28 @@ phpdbg_interact: } else { cleaning = 0; } + #ifndef _WIN32 - /* remote client disconnected */ - if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { + if (!cleaning) { + /* remote client disconnected */ + if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { - if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { - /* renegociate connections */ - phpdbg_open_sockets( - address, listen, &server, &socket, streams); + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + /* renegociate connections */ + phpdbg_open_sockets( + address, listen, &server, &socket, streams); - /* set streams */ - if (streams[0] && streams[1]) { - PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; + /* set streams */ + if (streams[0] && streams[1]) { + PHPDBG_G(flags) &= ~PHPDBG_IS_QUITTING; + } + + /* this must be forced */ + CG(unclean_shutdown) = 0; + } else { + /* local consoles cannot disconnect, ignore EOF */ + PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; } - - /* this must be forced */ - CG(unclean_shutdown) = 0; - } else { - /* local consoles cannot disconnect, ignore EOF */ - PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; } } #endif From c205a6f3de9d8923c2be6e16b1edc332981313a3 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Fri, 17 Jan 2014 21:20:19 +0000 Subject: [PATCH 14/16] zts fix --- phpdbg_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 501d0b8bf6..c24f08d6b1 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -477,7 +477,7 @@ disconnect: #ifndef HAVE_LIBREADLINE char buf[PHPDBG_MAX_CMD]; if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { - if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_CC))) { + if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) { goto disconnect; } } From 31a2ac470cba47a396a9b6c815700fbec51c6032 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 18 Jan 2014 12:30:44 +0100 Subject: [PATCH 15/16] Fix argument unpacking across stack pages If multiple unpacks were used (or mixed with normal arguments) parts of the arguments could land on different stack pages. If this occurs the arguments will now be copied to a new stack page. The code used to do this is copied verbatim from the PHP 5.4 branch and only modified to reduce the amount of inlined code. --- Zend/tests/arg_unpack/many_args.phpt | 15 ++++++++++++ Zend/zend_execute.c | 36 ++++++++++++++++++++++++++++ Zend/zend_vm_def.h | 8 +++++-- Zend/zend_vm_execute.h | 8 +++++-- 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 Zend/tests/arg_unpack/many_args.phpt diff --git a/Zend/tests/arg_unpack/many_args.phpt b/Zend/tests/arg_unpack/many_args.phpt new file mode 100644 index 0000000000..0ef5a30d6d --- /dev/null +++ b/Zend/tests/arg_unpack/many_args.phpt @@ -0,0 +1,15 @@ +--TEST-- +Argument unpacking with many arguments +--FILE-- + +--EXPECT-- +int(20000) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 174b165c7e..31caceecbe 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1691,6 +1691,42 @@ static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(zend_op *oplin } /* }}} */ +static void **zend_vm_stack_push_args_with_copy(int count TSRMLS_DC) /* {{{ */ +{ + zend_vm_stack p = EG(argument_stack); + + zend_vm_stack_extend(count + 1 TSRMLS_CC); + + EG(argument_stack)->top += count; + *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count; + while (count-- > 0) { + void *data = *(--p->top); + + if (UNEXPECTED(p->top == ZEND_VM_STACK_ELEMETS(p))) { + zend_vm_stack r = p; + + EG(argument_stack)->prev = p->prev; + p = p->prev; + efree(r); + } + *(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + count) = data; + } + return EG(argument_stack)->top++; +} +/* }}} */ + +static zend_always_inline void** zend_vm_stack_push_args(int count TSRMLS_DC) /* {{{ */ +{ + if (UNEXPECTED(EG(argument_stack)->top - ZEND_VM_STACK_ELEMETS(EG(argument_stack)) < count) + || UNEXPECTED(EG(argument_stack)->top == EG(argument_stack)->end)) { + return zend_vm_stack_push_args_with_copy(count TSRMLS_CC); + } + *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count; + return EG(argument_stack)->top++; +} +/* }}} */ + + #define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ ZEND_VM_INC_OPCODE(); \ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 37af82cef2..1e8a831551 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1947,8 +1947,12 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) } num_args = opline->extended_value + EX(call)->num_additional_args; - EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); - zend_vm_stack_push((void*)(zend_uintptr_t) num_args TSRMLS_CC); + if (EX(call)->num_additional_args) { + EX(function_state).arguments = zend_vm_stack_push_args(num_args TSRMLS_CC); + } else { + EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); + zend_vm_stack_push((void*)(zend_uintptr_t) num_args TSRMLS_CC); + } LOAD_OPLINE(); if (fbc->type == ZEND_INTERNAL_FUNCTION) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 0651389f74..7e613cd6e8 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -527,8 +527,12 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR } num_args = opline->extended_value + EX(call)->num_additional_args; - EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); - zend_vm_stack_push((void*)(zend_uintptr_t) num_args TSRMLS_CC); + if (EX(call)->num_additional_args) { + EX(function_state).arguments = zend_vm_stack_push_args(num_args TSRMLS_CC); + } else { + EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); + zend_vm_stack_push((void*)(zend_uintptr_t) num_args TSRMLS_CC); + } LOAD_OPLINE(); if (fbc->type == ZEND_INTERNAL_FUNCTION) { From 5b906ce6eb02118697c2f81d462ddfa724377fe8 Mon Sep 17 00:00:00 2001 From: Will Fitch Date: Sat, 18 Jan 2014 11:25:53 -0500 Subject: [PATCH 16/16] Fix bug #66509: copy() arginfo incorrect since 5.4 Since 5.4, the ZEND_BEGIN_ARG_INFO_EX was replaced by non _EX, causing Reflection to assume the $context parameter is required. --- NEWS | 1 + ext/standard/basic_functions.c | 2 +- ext/standard/tests/file/bug66509.phpt | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/file/bug66509.phpt diff --git a/NEWS b/NEWS index 81f88bf07f..00a0a940ad 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ PHP NEWS - Core: . Fixed bug #66286 (Incorrect object comparison with inheritance). (Nikita) + . Fixed bug #66509 (copy() arginfo has changed starting from 5.4). (willfitch) - Session: . Fixed bug #66481 (Calls to session_name() segfault when session.name is diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 5f880d74dd..c01365589e 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1206,7 +1206,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_fstat, 0) ZEND_ARG_INFO(0, fp) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_copy, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_copy, 0, 0, 2) ZEND_ARG_INFO(0, source_file) ZEND_ARG_INFO(0, destination_file) ZEND_ARG_INFO(0, context) diff --git a/ext/standard/tests/file/bug66509.phpt b/ext/standard/tests/file/bug66509.phpt new file mode 100644 index 0000000000..0e414f2321 --- /dev/null +++ b/ext/standard/tests/file/bug66509.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #66509 (copy() showing $context parameter as required) +--FILE-- +getParameters() as $p) { + var_dump($p->isOptional()); +} +?> +--EXPECT-- +bool(false) +bool(false) +bool(true)