From: alexander dot carver at gmail dot com Operating system: Debian 6.0 PHP version: 5.4.4 Package: Reflection related Bug Type: Bug Bug description:Attempting to invoke a Closure more than once causes segfault
Description: ------------ The code below should be fairly self-explanatory. Invoking a reflection of the __invoke method of the Closure class more than once per reflection instance causes a segfault. This happens regardless of context or argument parameters passed to ReflectionMethod::invokeArgs(). Can't imagine this is a common use case but thought I'd share anyway. PHP Version is 5.3.14. I don't have php configured to get a backtrace at the moment, and my .ini is pretty average. If you can't reproduce it with the script below I'll look into it more. php5 -m : [PHP Modules] apc bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter ftp gd gettext hash iconv json libxml mbstring mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix readline Reflection session shmop SimpleXML soap sockets SPL SQLite sqlite3 ssh2 standard sysvmsg sysvsem sysvshm tokenizer wddx xdebug xml xmlreader xmlwriter yaml zip zlib [Zend Modules] Xdebug Test script: --------------- <?php $closure1 = function($val){ return $val; }; $closure2 = function($val){ return $val; }; $reflection_class = new ReflectionClass($closure1); $reflection_method = $reflection_class->getMethod('__invoke'); $arguments1 = array('hello'); $arguments2 = array('world'); // Invoking once is OK... print $reflection_method->invokeArgs($closure1, $arguments1); if(true){ // But don't do it again! #print $reflection_method->invokeArgs($closure1, $arguments1); // Using different arguments per invokation makes no difference :( #print $reflection_method->invokeArgs($closure1, $arguments2); // Doesn't matter if you attempt to invoke a different closure with the same reflection. print $reflection_method->invokeArgs($closure2, $arguments1); } ?> Expected result: ---------------- "helloworld" printed Actual result: -------------- Segmentationfault -- Edit bug report at https://bugs.php.net/bug.php?id=62384&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62384&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62384&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62384&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62384&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62384&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62384&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62384&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62384&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62384&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62384&r=support Expected behavior: https://bugs.php.net/fix.php?id=62384&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62384&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62384&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62384&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62384&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62384&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62384&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62384&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62384&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62384&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62384&r=mysqlcfg