Bug #60509 [Fbk->Csd]: pcntl_signal doesn't decrease ref-count of old handler when setting SIG_DFL

From: Date: Fri, 05 Dec 2014 07:00:53 +0000
Subject: Bug #60509 [Fbk->Csd]: pcntl_signal doesn't decrease ref-count of old handler when setting SIG_DFL
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188926@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60509&edit=1

 ID:                 60509
 Updated by:         ab@php.net
 Reported by:        mplomer at gmx dot de
 Summary:            pcntl_signal doesn't decrease ref-count of old
                     handler when setting SIG_DFL
-Status:             Feedback
+Status:             Closed
 Type:               Bug
 Package:            PCNTL related
 Operating System:   Debian Squeeze
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=19b5bc8ce22b1476eb084a8b64c137bb8b17d674
Log: Fix #60509, pcntl_signal doesn't decrease ref-count of old handler


Previous Comments:
------------------------------------------------------------------------
[2014-11-29 13:53:24] jpauli@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.5-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------
[2014-11-29 13:53:17] jpauli@php.net

Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=19b5bc8ce22b1476eb084a8b64c137bb8b17d674
Log: Fix #60509, pcntl_signal doesn't decrease ref-count of old handler

------------------------------------------------------------------------
[2014-11-29 13:52:50] jpauli@php.net

Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=19b5bc8ce22b1476eb084a8b64c137bb8b17d674
Log: Fix #60509, pcntl_signal doesn't decrease ref-count of old handler

------------------------------------------------------------------------
[2014-11-29 13:52:24] jpauli@php.net

Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=19b5bc8ce22b1476eb084a8b64c137bb8b17d674
Log: Fix #60509, pcntl_signal doesn't decrease ref-count of old handler

------------------------------------------------------------------------
[2011-12-13 09:30:35] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=60509&edit=1


Thread (5 messages)

« previous php.bugs (#188926) next »