amphp / ext-uv

Other
191 stars 28 forks source link

Segmentation fault #84

Closed enumag closed 3 years ago

enumag commented 4 years ago

When I added ext-uv into my Dockerfile I started getting a segfault. I then simplified my Dockerfile as much as possible to give you a reproducer.

What I find curious is that the problem is gone if I remove docker-php-ext-install sockets. Does it mean that ext-uv is incompatible with ext-sockets or something?

Anyway here is the Dockerfile:

ARG PHP_VERSION=7.4

FROM composer AS composer

FROM php:${PHP_VERSION}-alpine AS extensions

RUN apk add --no-cache libuv-dev ${PHPIZE_DEPS} && \
    docker-php-ext-install sockets && \
    pecl install uv-beta && \
    docker-php-ext-enable uv

FROM php:${PHP_VERSION}-alpine

WORKDIR /usr/app

ENV COMPOSER_NO_INTERACTION=1 \
    COMPOSER_ALLOW_SUPERUSER=1 \
    COMPOSER_HTACCESS_PROTECT=0 \
    COMPOSER_MEMORY_LIMIT=-1

COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=extensions /usr/local/lib/php/extensions /usr/local/lib/php/extensions
COPY --from=extensions /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d

RUN apk add --no-cache libuv && \
    composer global require hirak/prestissimo --no-progress --no-suggest && \
    composer clear-cache
TheTechsTech commented 4 years ago

What I find curious is that the problem is gone if I remove docker-php-ext-install sockets. Does it mean that ext-uv is incompatible with ext-sockets or something?

It might be issue with just docker-php-ext-install you are using, cause ext-uv requires the socket to be enabled to work.

I have travis ci building the extension on tests, using somewhat the same steps you have.

enumag commented 4 years ago

Nah, that part is fine. docker-php-ext-install does enable the extension. It's not a priority issue either. Sockets extension is in the configuration sooner than uv.

TheTechsTech commented 4 years ago

Sockets extension is in the configuration sooner than uv.

Yes, on default PHP Linux system installs, not so with Windows, needs php.ini changes.

I have auto build setups for the following systems without issue:

For Debian like distributions, Ubuntu...

apt-get install libuv1-dev php-pear -y

For RedHat like distributions, CentOS...

yum install libuv-devel php-pear -y

Now have Pecl auto compile, install, and setup.

pecl channel-update pecl.php.net
pecl install uv-beta
enumag commented 4 years ago

Might be an Alpine-specific issue then. I didn't have any problems with ext-uv on Ubuntu either.

TheTechsTech commented 4 years ago

It might just be an general issue with PHP ZTS versions, after reading thru some of the other issues posted.

I have been testing uv_spawn with a wrapper for it, and getting segmentation faults/stalls or the build would pass, but then fail/error the build on code coverage creation.

This would not happen with the NTS, just ZTS.

enumag commented 4 years ago

@techno-express I tried again with NTS, the segfault still happens so it's not a ZTS problem. I've updated the Dockerfile in the first post accordingly.

enumag commented 4 years ago

I managed to get backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00007fe98602bce6 in zm_startup_uv (type=<optimized out>, 
    module_number=<optimized out>) at /tmp/pear/temp/uv/php_uv.c:2679
2679    /tmp/pear/temp/uv/php_uv.c: No such file or directory.
(gdb) bt
#0  0x00007fe98602bce6 in zm_startup_uv (type=<optimized out>, 
    module_number=<optimized out>) at /tmp/pear/temp/uv/php_uv.c:2679
#1  0x0000563cad879a17 in zend_startup_module_ex ()
#2  0x0000563cad879aac in zend_startup_module_zval ()
#3  0x0000563cad886c02 in zend_hash_apply ()
#4  0x0000563cad879d8a in zend_startup_modules ()
#5  0x0000563cad817ac6 in php_module_startup ()
#6  0x0000563cad8fcebd in php_cli_startup ()
#7  0x0000563cad5c5425 in main ()

I simplified the Dockerfile to this:

ARG PHP_VERSION=7.4

FROM wodby/base-php:${PHP_VERSION}-debug

RUN apk add --no-cache libuv-dev ${PHPIZE_DEPS} && \
    docker-php-ext-install sockets && \
    pecl install uv-beta && \
    docker-php-ext-enable uv

RUN apk add --no-cache libuv gdb

and then:

docker build .
docker run -it <image> sh
gdb php
run
bt
enumag commented 4 years ago

@bwoebi Is this enough for you to fix it?

enumag commented 4 years ago

Any news on this?

enumag commented 4 years ago

Note: I simplified the Dockerfile as much as possible. The segfault still happens.

TheTechsTech commented 4 years ago

Do you have the same issue with on non-alpine base, docker images? There is a reason why Alpine Linux sizes are so. The build, the tooling and everything based on musl libc https://musl.libc.org/ and Busybox http://busybox.net/.

Might be a issue it can't resolve by not being glibc base.

enumag commented 4 years ago

Yeah, this seems to be an alpine-specific issue. No other PHP extensions have any problem with it though and I'm using quite a few.

enumag commented 4 years ago

bump

WyriHaximus commented 3 years ago

Any news on this?

enumag commented 3 years ago

ping @bwoebi

enumag commented 3 years ago

Thanks @bwoebi! Would you mind releasing v0.2.3 with fixes like this one? There is a lot of unreleased ones. v0.3 might take a while to finish and afaik changes the API as well so it would be best to have a fixed 0.2 version available.