diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-05-27 18:26:32 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-02 15:17:40 +0200 |
commit | af4a9bf1bf9109714e0e45aaf907e9809abb6217 (patch) | |
tree | a5eda3272e96ffc8fab505d3e12d0d1fa681863b /sapi/phpdbg | |
parent | 461135009c9c5e5a5839f22aff23ee7c896fb730 (diff) | |
download | php-git-af4a9bf1bf9109714e0e45aaf907e9809abb6217.tar.gz |
Fix #73927: phpdbg fails with windows error prompt at "watch array"
We expect zvals, so we should request zvals.
We also suppress spurious watchpoint removal notices.
Diffstat (limited to 'sapi/phpdbg')
-rw-r--r-- | sapi/phpdbg/phpdbg_utils.c | 6 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_watch.c | 5 | ||||
-rw-r--r-- | sapi/phpdbg/tests/bug73927.phpt | 51 |
3 files changed, 55 insertions, 7 deletions
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index dca70deb8f..d32f2fb7f8 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -473,11 +473,7 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable if (new_index && index_len == 0) { zend_ulong numkey; zend_string *strkey; - ZEND_HASH_FOREACH_KEY_PTR(parent, numkey, strkey, zv) { - while (Z_TYPE_P(zv) == IS_INDIRECT) { - zv = Z_INDIRECT_P(zv); - } - + ZEND_HASH_FOREACH_KEY_VAL_IND(parent, numkey, strkey, zv) { if (i == len || (i == len - 1 && input[len - 1] == ']')) { char *key, *propkey; size_t namelen, keylen; diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index 317aa9666a..1dab755171 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -713,8 +713,9 @@ void phpdbg_automatic_dequeue_free(phpdbg_watch_element *element) { child = child->child; } PHPDBG_G(watchpoint_hit) = 1; - phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s has been removed, removing watchpoint%s", (int) ZSTR_LEN(child->str), ZSTR_VAL(child->str), (child->flags & PHPDBG_WATCH_RECURSIVE_ROOT) ? " recursively" : ""); - zend_hash_index_del(&PHPDBG_G(watch_elements), child->id); + if (zend_hash_index_del(&PHPDBG_G(watch_elements), child->id) == SUCCESS) { + phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s has been removed, removing watchpoint%s", (int) ZSTR_LEN(child->str), ZSTR_VAL(child->str), (child->flags & PHPDBG_WATCH_RECURSIVE_ROOT) ? " recursively" : ""); + } phpdbg_free_watch_element_tree(element); } diff --git a/sapi/phpdbg/tests/bug73927.phpt b/sapi/phpdbg/tests/bug73927.phpt new file mode 100644 index 0000000000..81a1d2fa47 --- /dev/null +++ b/sapi/phpdbg/tests/bug73927.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #73927 (phpdbg fails with windows error prompt at "watch array") +--PHPDBG-- +b 19 +r +c +w $value +w $lower[] +q +--EXPECTF-- +[Successful compilation of %s] +prompt> [Breakpoint #0 added at %s:%d] +prompt> [Breakpoint #0 at %s:%d, hits: 1] +>00019: if ($value < 100) { + 00020: $lower[] = $value; + 00021: } else { +prompt> [Breakpoint #0 at %s:%d, hits: 2] +>00019: if ($value < 100) { + 00020: $lower[] = $value; + 00021: } else { +prompt> [Added watchpoint #0 for $value] +prompt> [Added watchpoint #1 for $lower[0]] +prompt> [$lower[0] has been removed, removing watchpoint] +[$value has been removed, removing watchpoint] +--FILE-- +<?php + +// Generate some mock data +$example = [1, 23, 23423, 256436, 3463, 4363, 457]; +foreach (range(1, 1000) as $val) { + $example[] = mt_rand(1, 10000); +} + +// Stuff to debug +function doCoolStuff($value) +{ + $value++; + + return mt_rand(1, 1000); +} + +$lower = []; +foreach ($example as $key => $value) { + if ($value < 100) { + $lower[] = $value; + } else { + doCoolStuff($value); + } +} + +?> |