php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72774 Exception backtrace produces unexpected values
Submitted: 2016-08-07 13:56 UTC Modified: 2016-08-07 17:20 UTC
From: eyalt@php.net Assigned: cmb (profile)
Status: Closed Package: Variables related
PHP Version: 7.0.9 OS: Linux
Private report: No CVE-ID: None
 [2016-08-07 13:56 UTC] eyalt@php.net
Description:
------------
Exception backtrace produces wrong integer values when passed by reference - a regression VS PHP 5.x, as can be seen in the test script.

Test script:
---------------
<pre><?php
function recurse_bug($count) {
	if ($count) {
		return recurse_bug(--$count); // if we use instead $count - 1, then BT will be prodcued OK on PHP 7 too
	}
	$e = new Exception();
	print $e->getTraceAsString();
}
recurse_bug(2);
/*  On PHP 5.x we will get the correct BT:
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(1)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(2)
#3 {main}

On PHP 7.x we will get the following wrong BT:
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(1)
#3 {main} */

Expected result:
----------------
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(1)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(2)
#3 {main}

Actual result:
--------------
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(1)
#3 {main} */

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-07 16:57 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-08-07 16:57 UTC] cmb@php.net
As of PHP 7.0.0 this is expected behavior, that is described in
UPGRADING[1].

I couldn't find it being listed in the migration guide in the
manual, though, so I'm switching to doc bug.

[1] <https://github.com/php/php-src/blob/PHP-7.0.0/UPGRADING#L215-L240>
 [2016-08-07 17:19 UTC] cmb@php.net
-Summary: Exception backtrace produces wrong integer values when passed by reference +Summary: Exception backtrace produces unexpected values
 [2016-08-07 17:19 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339817
Log: Fix #72774: Exception backtrace produces unexpected values
 [2016-08-07 17:20 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2016-08-07 17:20 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=215778c3882fb5aca68beced599428c8d14e38e8
Log: Fix #72774: Exception backtrace produces unexpected values
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC