From: fiw at mail dot ru Operating system: FreeBSD 6.1 PHP version: 5.1.6 PHP Bug Type: PCNTL related Bug description: Self-call __destructor from child process
Description: ------------ No descriptions, sorry. Reproduce code: --------------- <?php declare(ticks = 1); class Daemon { private $threads = array(); function __construct() { echo posix_getpid() . ' Daemon::construct()' . "\n"; for ($i = 0; $i < 5; $i++) $threads[] = new Thread; } function __destruct() { echo posix_getpid() . ' Daemon::destruct()' . "\n"; } } class Thread { function __construct() { echo posix_getpid() . ' Thread::construct()' . "\n"; $this->pid = pcntl_fork(); if ($this->pid == -1) throw new Exception; if ($this->pid) { pcntl_wait($status); return; } echo posix_getpid() . ' Thread::child()' . "\n"; exit; } function __destruct() { echo posix_getpid() . ' Thread::destruct()' . "\n"; } } new Daemon; ?> Expected result: ---------------- 77080 Daemon::construct() 77080 Thread::construct() 77081 Thread::child() 77081 Daemon::destruct() 77081 Thread::destruct() 77080 Thread::construct() 77082 Thread::child() 77082 Daemon::destruct() 77082 Thread::destruct() 77082 Thread::destruct() 77080 Thread::construct() 77083 Thread::child() 77083 Daemon::destruct() 77083 Thread::destruct() 77083 Thread::destruct() 77083 Thread::destruct() 77080 Thread::construct() 77084 Thread::child() 77084 Daemon::destruct() 77084 Thread::destruct() 77084 Thread::destruct() 77084 Thread::destruct() 77084 Thread::destruct() 77080 Thread::construct() 77085 Thread::child() 77085 Daemon::destruct() 77085 Thread::destruct() 77085 Thread::destruct() 77085 Thread::destruct() 77085 Thread::destruct() 77085 Thread::destruct() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Daemon::destruct() Actual result: -------------- 77080 Daemon::construct() 77080 Thread::construct() 77081 Thread::child() 77080 Thread::construct() 77082 Thread::child() 77080 Thread::construct() 77083 Thread::child() 77080 Thread::construct() 77084 Thread::child() 77080 Thread::construct() 77085 Thread::child() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Thread::destruct() 77080 Daemon::destruct() -- Edit bug report at http://bugs.php.net/?id=38796&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38796&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38796&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38796&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38796&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38796&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38796&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38796&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38796&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38796&r=support Expected behavior: http://bugs.php.net/fix.php?id=38796&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38796&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38796&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38796&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38796&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38796&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38796&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38796&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38796&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38796&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38796&r=mysqlcfg