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