From: tater at potatoe dot com Operating system: OS X 10.2 PHP version: 5CVS-2003-11-16 (dev) PHP Bug Type: Strings related Bug description: switch on string offset crashes w/bus error
Description: ------------ a switch() statement testing a string offset, like 'switch($string{0})', crashes after executing the matching case or default block. this only happens if there is at least one case. workarounds: assign offset to another variable first, or put it in quotes like "{$string{0}}". This breaks a lot of PEAR code, btw. Reproduce code: --------------- $x = 'abc'; switch ($x{0}) { default: print "default - works\n"; } switch ($x{0}) { case 'a': print "case 'a' - bus error\n"; } print "done\n"; Expected result: ---------------- default - works case 'a' - bus error done Actual result: -------------- default - works case 'a' - bus error Bus error -------------------- backtrace: (gdb) run bug.php Starting program: /usr/local/book/php/bin/php bug.php [Switching to process 5410 thread 0xb03] Reading symbols for shared libraries . done Reading symbols for shared libraries ............ done default - works case 'a' - bus error Program received signal EXC_BAD_ACCESS, Could not access memory. 0x00229f8c in _zval_dtor (zvalue=0xbb4c10, __zend_filename=0x2c2a24 "/Users/tater/book/php-src/Zend/zend_execute.c", __zend_lineno=203) at /Users/tater/book/php-src/Zend/zend_variables.c:44 44 CHECK_ZVAL_STRING_REL(zvalue); (gdb) -- Edit bug report at http://bugs.php.net/?id=26281&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26281&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26281&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26281&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26281&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26281&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=26281&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26281&r=support Expected behavior: http://bugs.php.net/fix.php?id=26281&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26281&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26281&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26281&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26281&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26281&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26281&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26281&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26281&r=float