Bug #70547 [NEW]: unsetting function variables corrupts backtrace

From: Date: Mon, 21 Sep 2015 15:39:24 +0000
Subject: Bug #70547 [NEW]: unsetting function variables corrupts backtrace
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196134@lists.php.net to get a copy of this message
From:             classicScott at gmail dot com
Operating system: Ubuntu 14.04
PHP version:      7.0.0RC3
Package:          Performance problem
Bug Type:         Bug
Bug description:unsetting function variables corrupts backtrace

Description:
------------
If an arugment is unset inside of a function, it is also unset from
the call stack and corrupts the argument array in the backtrace. This
leads to a corrupt array that has a count > 0 and no elements within it.
This happens with both debug_backtrace() and getTraceAsString() in the
\Exception class.

Test script:
---------------
https://gist.github.com/terpfear/4adab63546659d1f3cab

Expected result:
----------------
Results obtained from php 5.5.9
array(2) {
  [0] =>
  string(6) "string"
  [1] =>
  string(13) "anything else"
}
	1) /home/scottf/sandbox/funsies/phpFun/php7BreakingArray.php(18):
brokenTrace('string', 'anything else')

unsetting arg1
array(2) {
  [0] =>
  string(6) "string"
  [1] =>
  string(13) "anything else"
}
	1) /home/scottf/sandbox/funsies/phpFun/php7BreakingArray.php(18):
brokenTrace('string', 'anything else')

unsetting arg2
array(2) {
  [0] =>
  string(6) "string"
  [1] =>
  string(13) "anything else"
}
	1) /home/scottf/sandbox/funsies/phpFun/php7BreakingArray.php(18):
brokenTrace('string', 'anything else')


Actual result:
--------------
array(2) {
  [0]=>
  string(6) "string"
  [1]=>
  string(13) "anything else"
}
	1) /home/scottf/sandbox/funsies/phpFun/php7BreakingArray.php(18):
brokenTrace('string', 'anything else')

unsetting arg1
array(2) {
  [1]=>
  string(13) "anything else"
}
	1) /home/scottf/sandbox/funsies/phpFun/php7BreakingArray.php(18):
brokenTrace('anything else')

unsetting arg2
array(2) {
}
	1) /home/scottf/sandbox/funsies/phpFun/php7BreakingArray.php(18):
brokenTrace()


-- 
Edit bug report at https://bugs.php.net/bug.php?id=70547&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70547&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70547&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70547&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70547&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70547&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70547&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70547&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70547&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70547&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70547&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70547&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70547&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70547&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70547&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70547&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70547&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70547&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70547&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70547&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70547&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#196134) next »