From: Operating system: OS X 10.7 PHP version: 5.3.6 Package: Reproducible crash Bug Type: Bug Bug description:Using reference variable to $this in callback causes a segfault
Description: ------------ Using a reference variable to $this within an anonymous function, in a class function causes a segfault. This previously worked in PHP 5.3.5. The segfault can be caused either when using the function as a closure, or as an anonymous function. The GDB output: GNU gdb 6.3.50-20050815 (Apple version gdb-1705) (Fri Jul 1 10:50:06 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ...................... done (gdb) run segfault.php Starting program: /usr/bin/php segfault.php Reading symbols for shared libraries +++++++++++++++++++++........................................................... ............................................................... done Reading symbols for shared libraries . done Reading symbols for shared libraries . done Reading symbols for shared libraries . done Reading symbols for shared libraries . done Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x00000001ffffffff 0x000000010035d53d in zend_std_get_method () Test script: --------------- <?php class Seg { public function fault() { $that = &$this; $callback = function() use ($that){}; $callback(); // Causes a segfault is_callable(function() use ($that){}); // Causes a segfault } } $obj = new Seg(); for($i = 0; $i < 5000; $i++) { $obj->fault(); } Expected result: ---------------- No segfault Actual result: -------------- Segfault -- Edit bug report at https://bugs.php.net/bug.php?id=55365&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55365&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55365&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55365&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55365&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55365&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55365&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55365&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55365&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55365&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55365&r=support Expected behavior: https://bugs.php.net/fix.php?id=55365&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55365&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55365&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55365&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55365&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55365&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55365&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55365&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55365&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55365&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55365&r=mysqlcfg