What did you do? If possible, provide a simple script for reproducing the error.
I created this simple script to be able to create a coroutine inside a server task.
*******
<?php
$server = new OpenSwoole\Server("127.0.0.1", 9501, OpenSwoole\Server::SIMPLE_MODE);
$server->set( [ 'worker_num' => 1,
'task_worker_num' => 1,
'task_enable_coroutine' => true ]);
$server->on('Receive', function (OpenSwoole\Server $server, $fd, $reactorId, $data)
{
4. What version of OpenSwoole are you using (show your `php --ri openswoole`)?
openswoole
Open Swoole => enabled
Author => Open Swoole Group hello@openswoole.com
Version => 22.0.0
Built => Dec 22 2022 13:01:47
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 3.0.2 15 Mar 2022
dtls => enabled
http2 => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
postgresql => enabled
Directive => Local Value => Master Value
openswoole.enable_coroutine => On => On
openswoole.enable_preemptive_scheduler => Off => Off
openswoole.display_errors => On => On
openswoole.unixsock_buffer_size => 8388608 => 8388608
5. What is your machine environment used (show your `uname -a` & `php -v` & `gcc -v`) ?
Note I am running openswoole under WSL1 Ubuntu 22.04
uname -a :
Linux PC-XXXXX 4.4.0-19041-Microsoft #3570-Microsoft Fri Sep 29 17:00:00 PST 2023 x86_64 x86_64 x86_64 GNU/Linux
php -v :
PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies
$server->on('Receive', function (OpenSwoole\Server $server, $fd, $reactorId, $data) {
$server->task("taskcallback", -1, function (OpenSwoole\Server $server, $task_id, $data) { echo 'starting task' . PHP_EOL; });
});
$server->on("Task", function(OpenSwoole\Server $server, OpenSwoole\Server\Task $task ) { var_dump($task); Co::run(function() { Co::sleep(1); // } }); });
When I telnet localhost 9501 the program crashes.
I expect the coroutine inside the task to make a sleep and exit
program crashes with the following error :
[2023-11-08 19:08:27 $590.0] WARNING Server::check_worker_exit_status(): worker(pid=591, id=1) abnormal exit, status=0, signal=11 A bug occurred in OpenSwoole-v22.0.0, please report it. Please submit bug report at:
OS: Linux 4.4.0-19041-Microsoft #3570-Microsoft Fri Sep 29 17:00:00 PST 2023 x86_64 GCC_VERSION: 11.3.0 OPENSSL_VERSION: OpenSSL 3.0.2 15 Mar 2022 PHP_VERSION : 8.1.13
openswoole
Open Swoole => enabled Author => Open Swoole Group hello@openswoole.com Version => 22.0.0 Built => Dec 22 2022 13:01:47 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 3.0.2 15 Mar 2022 dtls => enabled http2 => enabled mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled postgresql => enabled
Directive => Local Value => Master Value openswoole.enable_coroutine => On => On openswoole.enable_preemptive_scheduler => Off => Off openswoole.display_errors => On => On openswoole.unixsock_buffer_size => 8388608 => 8388608
Note I am running openswoole under WSL1 Ubuntu 22.04
You can also try the following OpenSwoole support channels: