[php-src] Issue #8073: Calling debug_backtrace in a foreach cycle restarts the foreach cycle

From: Date: Mon, 21 Mar 2022 14:18:03 +0000
Subject: [php-src] Issue #8073: Calling debug_backtrace in a foreach cycle restarts the foreach cycle
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240436@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8073 Comment Author: dstogov @cmb69 Actually, the regression comes from d65d3f5298dcc8d94bcac96e8bf2441dceb393ac that added `ZVAL_DEREF() in debug_backtrace_get_args()` and started to increment reference-counter of referenced array instead of owning reference. In case you replace `$debug_backtrace[] = debug_backtrace(); by $debug_backtrace[] = $array;` you get the same behavior on old PHP versions (7.4) as well. This is expected. @andrejsverza To keep consistent behavior, I would recommend not to modify the iterating array inside the `foreach loop or not to use foreach` by reference.

« previous php.bugs (#240436) next »