php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48847 debug_backtrace() doesn't reference arguments in stack in some cases
Submitted: 2009-07-08 08:00 UTC Modified: 2013-02-17 10:29 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: an0nym at narod dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.10, 5.3.0 OS: *
Private report: No CVE-ID: None
 [2009-07-08 08:00 UTC] an0nym at narod dot ru
Description:
------------
When argument of function or method is defined with type declaration and 
default value and is called with some value of this argument, 
debug_backtrace() doesn't reference this argument of function in stack. 

When function definition is the same except argument doesn't have 
default value, everything goes normal. 

Reproduce code:
---------------
<?php function error($message,$number){
	$traces=debug_backtrace();
	$traces[1]['args'][0]='1';
	return TRUE;
}
set_error_handler('error');
function a(anyUndefinedType $a){ // E_RECOVERABLE_ERROR
	var_dump($a===1,$a==='1'); 
}
function b(anyUndefinedType $b=NULL){ // E_RECOVERABLE_ERROR
	var_dump($b===1,$b==='1'); 
}
a(1);
b(1); ?>

Expected result:
----------------
bool(false) bool(true)
bool(false) bool(true)

Actual result:
--------------
bool(false) bool(true)
bool(true) bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-25 07:21 UTC] sjoerd@php.net
Thank you for your bug report.

Why do you think it should be possible what you are trying to do? The documentation for debug_backtrace does not describe that it returns a reference. I am surprised that it is possible to change function parameters in the error handler, and I don't think it is supported behavior.
 [2009-08-25 09:04 UTC] an0nym at narod dot ru
I agree that manual doesn't document anything related to this issue - according to manual behaviour in this particular case is undefined, so 
de jure this is not a bug. 

However, I think behaviour should be at least equal in both cases I 
provided. Moreover, I don't see the point of triggering recoverable 
error when you can't influence the cause of it. 

> I am surprised that it is possible to change function
parameters in the error handler, and I don't think it is supported
behavior. 
I think it is OK to change function parameters in the error handler for 
catchable error which these function parameters were reason for. Maybe 
debug_backtrace() is not the appropriate tool to get there parameters, 
but there is no other.
 [2010-12-20 13:19 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2013-02-17 10:29 UTC] stas@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Modifying debug traces is definitely not a supported functionality.
 [2013-02-17 10:29 UTC] stas@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Dec 19 03:01:26 2018 UTC