报告bug:php8中workerman遇到异常会卡死不能重新fork一个子进程

0

代码:


global $worker;
$worker = new Worker();
Worker::$pidFile = '/dev/shm/jmworker.pid';
$worker->onWorkerStart = function(){
global $worker,$sec;
$sec = 0.5;
\Workerman\Lib\Timer::add($sec, function (){
echo '333333333333333';
//exit();
1/0;
},true);
};
// 运行worker
Worker::runAll();

遇到异常就会卡死不会退出进程,也不会重新fork一个子进程。执行exit()也不会、
比如数据库暂时无法连接,出现异常,就会导致子进程卡死不会退出,也不会重新fork一个子进程。


-------------------------------------- WORKERMAN --------------------------------------
Workerman version:4.0.19 PHP version:8.0.8
--------------------------------------- WORKERS ---------------------------------------
proto user worker listen processes status
tcp root jmworker_main none 1 [OK]
---------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
333333333333333DivisionByZeroError: Division by zero in /var/www/html/public/1.php:28
Stack trace:
#0 /var/www/html/vendor/workerman/workerman/Events/Event.php(167): {closure}(true)
#1 [internal function]: Workerman\Events\Event->timerCallback(-1, 1, Array)
#2 /var/www/html/vendor/workerman/workerman/Events/Event.php(195): EventBase->loop()
#3 /var/www/html/vendor/workerman/workerman/Worker.php(2430): Workerman\Events\Event->loop()
#4 /var/www/html/vendor/workerman/workerman/Worker.php(1554): Workerman\Worker->run()
#5 /var/www/html/vendor/workerman/workerman/Worker.php(1384): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
#6 /var/www/html/vendor/workerman/workerman/Worker.php(1358): Workerman\Worker::forkWorkersForLinux()
#7 /var/www/html/vendor/workerman/workerman/Worker.php(542): Workerman\Worker::forkWorkers()
#8 /var/www/html/public/1.php(33): Workerman\Worker::runAll()
#9 {main}

Warning: EventBase::loop(): Failed to invoke event callback in /var/www/html/vendor/workerman/workerman/Events/Event.php on line 195

Warning: EventBase::loop(): Failed to invoke event callback in /var/www/html/vendor/workerman/workerman/Events/Event.php on line 195

Warning: EventBase::loop(): Failed to invoke event callback in /var/www/html/vendor/workerman/workerman/Events/Event.php on line 195
已邀请:

six

赞同来自:

event扩展不是稳定版本?

dignfei - 丹妮

赞同来自:

有没有大佬解答一下

WilliamA

赞同来自:

你代码有致命错误,退出才是正常行为。workerman 在你进程出现致命错误之后就会重新 fork 一个进程的,但是你的致命错误又没有合理地处理,就会重复以上步骤。

MarkGo

赞同来自:

我剛測試了,
同樣配置下,
php7 + event + libevent2 表現正常。
php8 + event + libevent2 表現異常。
其中event和libevent2 是 相同版本的。
而且問題只有在Timer裡才會發生,
我是在FileMonitor裡,
實例化時添加1/0;
這時候php7/8 都會自動重啟。
如果在實例化添加Timer::add.....,
php7 會重啟,
php8 會一直報錯Failed to invoke event callback。


補充下:
opcache開啟關閉都試過,結果一樣。
event


Event support => enabled
Sockets support => enabled
Debug support => disabled
Extra functionality support including HTTP, DNS, and RPC => enabled
OpenSSL support => disabled
Thread safety support => disabled
Extension version => 3.0.5
libevent2 headers version => 2.1.8-stable


如果使用select模型不會出錯,只有event的timer才會異常,
感覺是event的問題。


還是使用php7.4,有高版本要求的就把event轉為select模型吧。

要回复问题请先登录注册