From:             cdragon at draconic dot com
Operating system: Windows 2000 Server
PHP version:      4CVS-2003-09-30 (stable)
PHP Bug Type:     Variables related
Bug description:  extract($GLOBALS, EXTR_REFS); can corrupt the $GLOBALS array.

Description:
------------
Using extract($GLOBALS, EXTR_REFS); can cause the left hand side of two
globals set "by-value" equal to one-another to become corrupted in the
$GLOBALS array.  Hard to explain in English, but easier to see in the code
below.

Reproduce code:
---------------
$sortColumn = "Affinity";
// Using "$lastSortColumn = substr($sortColumn, 0);" fixes the bug
$lastSortColumn = $sortColumn;

print "sort=" . $GLOBALS['sortColumn'] . " lastsort=" .
$GLOBALS['lastSortColumn'] . "<p>";
extractGlobs();
print "sort=" . $GLOBALS['sortColumn'] . " lastsort=" .
$GLOBALS['lastSortColumn'] . "<p>";

function extractGlobs()
{
  // Commenting out the line below fixes the bug.  So does not using the
EXTR_REFS flag.
  extract($GLOBALS, EXTR_REFS);
}

Expected result:
----------------
sort=Affinity lastsort=Affinity
sort=Affinity lastsort=Affinity


Actual result:
--------------
sort=Affinity lastsort=Affinity
sort=Affinity lastsort=

or, randomly, you get an access violation instead:

PHP has encountered an Access Violation at 02CFF32F
(the 02CFF32F is variable)

-- 
Edit bug report at http://bugs.php.net/?id=25708&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25708&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25708&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25708&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25708&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25708&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25708&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25708&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25708&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25708&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25708&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25708&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25708&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25708&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25708&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25708&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25708&r=float

Reply via email to