swoole / docker-swoole

šŸ„ Official Docker Image of Swoole
https://hub.docker.com/r/phpswoole/swoole
Apache License 2.0
526 stars 112 forks source link

Swoole alpine php8.3 composer fails with a segfault #45

Closed ghost closed 9 months ago

ghost commented 10 months ago

Hello, after updating the alpine php base image to v8.3.0, ext-swoole is installed and the application is running, but composer can neither install nor update.

  1. What did you do? If possible, provide a simple script for reproducing the error.
docker run -it --rm phpswoole/swoole:php8.3-alpine sh
composer init

Define any dependency or try to require later, e.g.:

composer require roave/security-advisories
  1. What did you expect to see?

Composer installation

  1. What did you see instead?

Segmentation fault

  1. What version of Swoole are you using (show your php --ri swoole)?

Swoole => enabled Author => Swoole Team team@swoole.com Version => 5.1.1 Built => Nov 27 2023 04:49:08 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 3.1.4 24 Oct 2023 dtls => enabled http2 => enabled json => enabled curl-native => enabled pcre => enabled zlib => 1.2.13 brotli => E16777225/D16777225 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled async_redis => enabled coroutine_pgsql => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_fiber_mock => Off => Off swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 8388608 => 8388608

liulyn commented 10 months ago

é‚®ä»¶å·²ę”¶åˆ° č°¢č°¢ļ¼

deminy commented 10 months ago

Thanks for reporting the issue. Reassigning to @matyhtf .

Steps to reproduce:

docker run --rm -ti phpswoole/swoole:5.1.1-php8.3-dev composer self-update ; echo $?

vs

docker run --rm -ti phpswoole/swoole:5.1.1-php8.2-dev composer self-update ; echo $?
ghost commented 10 months ago

This seems to be a problem with swoole-curl. If I build the image without that configuration, deminy's test passes. So does the issue belong more to swoole-src itself? https://github.com/swoole/docker-swoole/blob/b09ba4ef832b22f9e50163a08523595c0e4d23ed/dockerfiles/5.1.1/php8.3/alpine/Dockerfile#L26

Composer self-updates without swoole-curl:

docker-php-ext-configure swoole \
        --enable-mysqlnd      \
        --enable-swoole-pgsql \
        --enable-openssl      \
        --enable-sockets && \
docker-php-ext-install -j$(nproc) swoole && \
deminy commented 10 months ago

@devrla Yep, there could be new changes made to the curl extension between PHP 8.2 and 8.3, and the Swoole team didn't have those integrated into Swoole.

The team is aware of the issue and is working on a fix. In the meantime, removing/disabling installation option --enable-swoole-curl could be a temporary workaround to play with Swoole 5.1.1 on PHP 8.3, although I haven't yet tried it by myself.

Thanks

ghost commented 10 months ago

@deminy Thanks, the temporary workaround works for us. šŸ‘

mlocati commented 9 months ago

Installing swoole with --enable-swoole-curl set to yes leads to segmentation fault on Debian too (non only on Alpine).

Here's a sample script that causes segmentation fault if swoole is compiled with curl support: https://github.com/mlocati/docker-php-extension-installer/blob/2.1.69/scripts/tests/swoole

ghost commented 9 months ago

@mlocati We use the php extension installer for our images šŸ‘

The issue has already been fixed https://github.com/swoole/swoole-src/issues/5206

But while this test now passes...

docker run --rm -ti phpswoole/swoole:php8.3-alpine composer self-update ; echo $?

...a running container does not:

docker run --rm -ti phpswoole/swoole:php8.3-alpine sh
/var/www # composer self-update
Segmentation fault

Both behaviors probably have the same cause?

ghost commented 9 months ago

I have now tested all the variations from this thread again with the latest swoole alpine image. Both the composer and curl requests run without errors. The builds of our PHP 8.3 alpine images with Swoole extension are also successful. So I think the issue can be closed. Thanks to everyone who was involved in the solution.

tiagomichaelsousa commented 9 months ago

Hello there, is it possible to release also the changes for 5.1.1-php8.3-alpine?

From what I saw in GitHub workflows it will probably need a merge from the main branch to the 5.1.1 branch to update the image.

Thank you in advance šŸ™

deminy commented 9 months ago

@tiagomichaelsousa Unfortunately we can't. Docker image 5.1.1-php8.3-alpine was built for v5.1.1 of Swoole. The issue will be fixed in the next release of Swoole, but not in the released version (v5.1.1).

However, there are nightly images built using latest source code of Swoole from the master branch. Please feel free to try them (e.g., php8.3-alpine) a try and let us know if there are any questions.