Skip to content

Commit

Permalink
Merge branch 'PHP-8.3'
Browse files Browse the repository at this point in the history
* PHP-8.3:
  Fix phpGH-15901: phpdbg: Assertion failure on `i funcs`
  • Loading branch information
cmb69 committed Sep 18, 2024
2 parents 7bf5b7f + c76913f commit 7a8767f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 28 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ PHP NEWS
- Opcache:
. Fixed bug GH-15657 (Segmentation fault in dasm_x86.h). (nielsdos)

- PHPDBG:
. Fixed bug GH-15901 (phpdbg: Assertion failure on i funcs). (cmb)

- PCRE:
. Fix UAF issues with PCRE after request shutdown. (nielsdos)

Expand Down
60 changes: 32 additions & 28 deletions sapi/phpdbg/phpdbg_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,27 +399,29 @@ PHPDBG_INFO(classes) /* {{{ */
phpdbg_notice("User Classes (%d)", zend_hash_num_elements(&classes));

/* once added, assume that classes are stable... until shutdown. */
ZEND_HASH_PACKED_FOREACH_PTR(&classes, ce) {
phpdbg_print_class_name(ce);

if (ce->parent) {
if (ce->ce_flags & ZEND_ACC_LINKED) {
zend_class_entry *pce = ce->parent;
do {
phpdbg_out("|-------- ");
phpdbg_print_class_name(pce);
} while ((pce = pce->parent));
} else {
phpdbg_writeln("|-------- User Class %s (not yet linked because declaration for parent was not encountered when declaring the class)", ZSTR_VAL(ce->parent_name));
if (HT_IS_INITIALIZED(&classes)) {
ZEND_HASH_PACKED_FOREACH_PTR(&classes, ce) {
phpdbg_print_class_name(ce);

if (ce->parent) {
if (ce->ce_flags & ZEND_ACC_LINKED) {
zend_class_entry *pce = ce->parent;
do {
phpdbg_out("|-------- ");
phpdbg_print_class_name(pce);
} while ((pce = pce->parent));
} else {
phpdbg_writeln("|-------- User Class %s (not yet linked because declaration for parent was not encountered when declaring the class)", ZSTR_VAL(ce->parent_name));
}
}
}

if (ce->info.user.filename) {
phpdbg_writeln("|---- in %s on line %u", ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start);
} else {
phpdbg_writeln("|---- no source code");
}
} ZEND_HASH_FOREACH_END();
if (ce->info.user.filename) {
phpdbg_writeln("|---- in %s on line %u", ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start);
} else {
phpdbg_writeln("|---- no source code");
}
} ZEND_HASH_FOREACH_END();
}

zend_hash_destroy(&classes);

Expand All @@ -445,17 +447,19 @@ PHPDBG_INFO(funcs) /* {{{ */

phpdbg_notice("User Functions (%d)", zend_hash_num_elements(&functions));

ZEND_HASH_PACKED_FOREACH_PTR(&functions, zf) {
zend_op_array *op_array = &zf->op_array;
if (HT_IS_INITIALIZED(&functions)) {
ZEND_HASH_PACKED_FOREACH_PTR(&functions, zf) {
zend_op_array *op_array = &zf->op_array;

phpdbg_write("|-------- %s", op_array->function_name ? ZSTR_VAL(op_array->function_name) : "{main}");
phpdbg_write("|-------- %s", op_array->function_name ? ZSTR_VAL(op_array->function_name) : "{main}");

if (op_array->filename) {
phpdbg_writeln(" in %s on line %d", ZSTR_VAL(op_array->filename), op_array->line_start);
} else {
phpdbg_writeln(" (no source code)");
}
} ZEND_HASH_FOREACH_END();
if (op_array->filename) {
phpdbg_writeln(" in %s on line %d", ZSTR_VAL(op_array->filename), op_array->line_start);
} else {
phpdbg_writeln(" (no source code)");
}
} ZEND_HASH_FOREACH_END();
}

zend_hash_destroy(&functions);

Expand Down
10 changes: 10 additions & 0 deletions sapi/phpdbg/tests/gh15901.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
GH-15901 (phpdbg: Assertion failure on `i funcs`)
--PHPDBG--
i funcs
i classes
--EXPECT--
prompt> [User Functions (0)]
prompt> [User Classes (0)]
prompt> [User Classes (0)]
prompt>

0 comments on commit 7a8767f

Please sign in to comment.