pcntl_signal doesn't decrease ref-count of old handler when setting SIG_DFL
| Bug #60509 | pcntl_signal doesn't decrease ref-count of old handler when setting SIG_DFL | ||||
|---|---|---|---|---|---|
| Submitted: | 2011-12-13 09:30 UTC | Modified: | 2014-11-29 13:53 UTC | ||
| From: | mplomer at gmx dot de | Assigned: | |||
| Status: | Closed | Package: | PCNTL related | ||
| PHP Version: | 5.3.8 | OS: | Debian Squeeze | ||
| Private report: | No | CVE-ID: | None | ||
[2011-12-13 09:30 UTC] mplomer at gmx dot de
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2014-11-29 13:53 UTC] jpauli@php.net
-Status: Closed +Status: Feedback
[2014-12-05 07:00 UTC] ab@php.net
-Status: Feedback +Status: Closed
[2014-12-06 12:57 UTC] mplomer at gmx dot de