From:             info at tphnet dot com
Operating system: Windows XP (SP1)
PHP version:      4.3.2
PHP Bug Type:     *Programming Data Structures
Bug description:  Specific use of unset() (mistaking integer for array) crashes PHP

Description:
------------
When trying to unset() a multidimensional array which actually is an
integer, PHP will crash. Windows signals the program has generated a fatal
error and will be shutdown.

I had an array which looked something like this: $array[1][2][3] = 'value'
and I used unset($array[1][2][3]) to clear the value of this element of my
array.
At some point in my script I accidently replaced the value of $array with
a simple integer (e.g. $array = 'value'), so $array wasn't an array
anymore.
If i then tried to unset($array[1][2][3]), PHP would crash (after a few
seconds of running @ 100% cpu). I know the code is faulty, I don't think
it should be able to crash PHP...

I'm using Apache 2.0.45 with PHP as a module, but the crash also occours
when using the client version (php-cli.php on windows) from the command
prompt.

Note: The crash only occours when using multidimensional arrays.

Reproduce code:
---------------
<?

$array = 'test';

unset($array["lvl1"]["lvl2"]["b"]);

?>

Expected result:
----------------
When Using Apache:
Windows signals apache has generated a fatal error and will be closed.
Apache automatically restarts and resumes loading the webpage, thus
crashing again and getting stuck in an endless crashing loop (until you
close the browser).
When Using PHP CLI:
Windows signals PHP has generated a fatal error and will be closed, script
execution is terminated and you are returned to the command prompt.

Actual result:
--------------
AppName: php.exe
AppVer: 4.3.2.2
ModName: php4ts.dll
ModVer: 4.3.2.2
Offset: 000cf358

I've also saved the log windows generated when the crash occoured. It's
kinda long (in XML) and I don't know which (if any) part you require, so
let me know if you need.

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

Reply via email to