Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault #84

Closed
enumag opened this issue Mar 23, 2020 · 16 comments
Closed

Segmentation fault #84

enumag opened this issue Mar 23, 2020 · 16 comments

Comments

@enumag
Copy link

enumag commented Mar 23, 2020

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
Copy link

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
Copy link
Author

enumag commented Mar 23, 2020

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
Copy link

TheTechsTech commented Mar 23, 2020

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
Copy link
Author

enumag commented Mar 24, 2020

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

@TheTechsTech
Copy link

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
Copy link
Author

enumag commented Mar 28, 2020

@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
Copy link
Author

enumag commented Apr 20, 2020

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
Copy link
Author

enumag commented Apr 20, 2020

@bwoebi Is this enough for you to fix it?

@enumag
Copy link
Author

enumag commented May 12, 2020

Any news on this?

@enumag
Copy link
Author

enumag commented May 25, 2020

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

@TheTechsTech
Copy link

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
Copy link
Author

enumag commented May 25, 2020

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
Copy link
Author

enumag commented Sep 14, 2020

bump

@WyriHaximus
Copy link
Contributor

Any news on this?

@enumag
Copy link
Author

enumag commented Dec 28, 2020

ping @bwoebi

@bwoebi bwoebi closed this as completed in f7d052a Dec 29, 2020
@enumag
Copy link
Author

enumag commented Dec 29, 2020

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.

TheTechsTech added a commit to symplely/ext-uv that referenced this issue Mar 30, 2023
**In reference to:** amphp#106, amphp#107, amphp#94, amphp#98, amphp#93, amphp#92, amphp#86, amphp#84, amphp#82, amphp#64

- BC signature changes has been revert since some of the tests wasn't changed to match, and too far off original design.
- Using current **Libuv** version or systems installed one, not `pecl`, this setup is not reliant on the really slow `pecl` system for updated installations.

The whole `uv_queue_work()` will need to be re implemented, the core internal `TSRM.c` thread related `tsrm_***_interpreter_context` functions used in PHP 7.4 has been removed since PHP 8.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants