From: Operating system: Debian Squeeze PHP version: 5.3.8 Package: PCNTL related Bug Type: Bug Bug description:pcntl_signal doesn't decrease ref-count of old handler when setting SIG_DFL
Description: ------------ When overwriting an old signal handler (that references "$this" for example) with SIG_DFL, the reference counter on $this is not decreased, so when unsetting the object, it cannot be freed. My current workaround: When overwriting the signal handler with an empty function before ("function() {}"), the ref-count is correctly decreased (WTF?!), and the instance is immediately freed, when unsetting the object. Test script: --------------- class Test { public function __construct() { pcntl_signal(SIGUSR1, array($this, 'signalHandler'), false); //pcntl_signal(SIGUSR1, function() {}); // destruct works correctly when commenting in pcntl_signal(SIGUSR1, SIG_DFL); } public function signalHandler() { } public function __destruct() { echo '__destruct' . PHP_EOL; } } $test = new Test(); echo 'unsetting' . PHP_EOL; unset($test); echo 'end' . PHP_EOL; Expected result: ---------------- unsetting __destruct end Actual result: -------------- unsetting end __destruct -- Edit bug report at https://bugs.php.net/bug.php?id=60509&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60509&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60509&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60509&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60509&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60509&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60509&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60509&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60509&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60509&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60509&r=support Expected behavior: https://bugs.php.net/fix.php?id=60509&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60509&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60509&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60509&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60509&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60509&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60509&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60509&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60509&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60509&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60509&r=mysqlcfg