Bug #80907 [Opn]: Seg fault with pcntl_alarm() when triggered while waiting on IO
Edit report at https://bugs.php.net/bug.php?id=80907&edit=1
ID: 80907
User updated by: tobias dot nyholm at gmail dot com
Reported by: tobias dot nyholm at gmail dot com
Summary: Seg fault with pcntl_alarm() when triggered while
waiting on IO
Status: Open
Type: Bug
Package: PCNTL related
Operating System: OSX
PHP Version: 7.4.16
Block user comment: N
Private report: N
New Comment:
Thank you for trying to reproduce.
I've installed PHP with homebrew. The bug is present on PHP 7.4.10 and 7.4.14. Not on PHP 8.0.1
---------
⯠php -v
PHP 7.4.14 (cli) (built: Jan 5 2021 14:30:27) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies
with blackfire v1.48.1~mac-x64-non_zts74, https://blackfire.io, by Blackfire
⯠php alarm.php
.[1] 33291 segmentation fault php alarm.php
⯠php8 -v
PHP 8.0.1 (cli) (built: Jan 7 2021 17:26:28) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies
with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies
⯠php8 alarm.php
.PHP Fatal error: Uncaught RuntimeException: Maximum execution time reached in
/workspace/alarm.php:5
Stack trace:
#0 /workspace/alarm.php(13): {closure}(14, Array)
#1 /workspace/alarm.php(21): Worker->work()
#2 {main}
thrown in /workspace/alarm.php on line 5
Fatal error: Uncaught RuntimeException: Maximum execution time reached in /workspace/alarm.php on
line 5
RuntimeException: Maximum execution time reached in /workspace/alarm.php on line 5
Call Stack:
0.0003 464296 1. {main}() /workspace/alarm.php:0
0.0005 469392 2. Worker->work() /workspace/alarm.php:21
2.0052 469896 3. {closure:/workspace/alarm.php:4-6}(14, ['signo' => 14,
'errno' => 0, 'code' => 0]) /workspace/alarm.php:13
Previous Comments:
------------------------------------------------------------------------
[2021-03-25 20:55:11] dc dot link at yahoo dot fr
Was unable to reproduce it with Mac Intel and M1 with and without debug. Does it occur all the time
and was it build from source or is it homebrew/macports ?
------------------------------------------------------------------------
[2021-03-25 14:44:29] tobias dot nyholm at gmail dot com
Description:
------------
When using pcntl_alarm() and the alarm is triggered when waiting for IO inside a
class, I get a "42064 segmentation fault".
If the for loop is executing in the global namespace, everything is fine.
Test script:
---------------
<?php
pcntl_async_signals(true);
pcntl_signal(SIGALRM, function () {
throw new \RuntimeException('Maximum execution time reached');
});
pcntl_alarm(2);
class Worker
{
public function work()
{
for ($i = 0; $i< 10; $i++) {
echo '.';
sleep(5);
}
}
}
$worker = new Worker();
$worker->work();
echo "end";
Expected result:
----------------
.PHP Fatal error: Uncaught RuntimeException: Maximum execution time reached in
/Users/tobias/Workspace/PHPStorm/bref/alarm.php:5
Stack trace:
#0 /Users/tobias/Workspace/PHPStorm/bref/alarm.php(13): {closure}(14, Array)
#1 /Users/tobias/Workspace/PHPStorm/bref/alarm.php(21): Worker->work()
#2 {main}
thrown in /Users/tobias/Workspace/PHPStorm/bref/alarm.php on line 5
Actual result:
--------------
⯠php alarm.php
.[1] 41920 segmentation fault php alarm.php
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80907&edit=1
Thread (8 messages)