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

Segfault when running Psalm with JIT on the official 8.3 alpine ZTS image #12884

Closed
danog opened this issue Dec 6, 2023 · 2 comments
Closed

Comments

@danog
Copy link
Contributor

danog commented Dec 6, 2023

Description

The following Dockerfile:

FROM php:8.3-zts-alpine AS base

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN install-php-extensions opcache

RUN apk add git unzip

RUN git clone https://github.com/WyriHaximus/php-test-utilities/ \
    && php -r "readfile('https://getcomposer.org/installer');" | php \
	&& mv composer.phar /usr/bin/composer 

WORKDIR /php-test-utilities
RUN composer install --ignore-platform-reqs || true

ENV PSALM_ALLOW_XDEBUG=1

RUN php -dopcache.enable_cli=true -dopcache.jit_buffer_size=64M -dopcache.jit=1205 -dopcache.optimization_level=0x7FFEBFFF vendor/bin/psalm --shepherd --stats --config=./etc/qa/psalm.xml --no-cache

ENTRYPOINT ["docker-php-entrypoint"]

Resulted in a segfault, but I expected no segfault.

Ping @dstogov @WyriHaximus @Girgias

PHP Version

PHP 8.3.0

Operating System

No response

@danog danog changed the title Segfault when running Psalm on the official 8.3 alpine ZTS image Segfault when running Psalm with JIT on the official 8.3 alpine ZTS image Dec 6, 2023
@dstogov
Copy link
Member

dstogov commented Feb 5, 2024

I see the problem. It's related to Thread Local Storage implementation in MUSL.

It seems like 2b2aeb9 fixed some compilation issues, but not the real TLS address calculation in JIT.
So JIT in ZTS build never worked with MUSL.
I suppose we need some special support for MUSL at

php-src/ext/opcache/jit/zend_jit_x86.dasc:2898
 #if defined(__has_attribute) && __has_attribute(tls_model) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__MUSL__) 

Most probably we should use 8 instead of 16 at

php-src/ext/opcache/jit/zend_jit_x86.dasc:2911

 tsrm_tls_index = ti[0] * 16; 

@danong can you test this?

@dstogov
Copy link
Member

dstogov commented Feb 12, 2024

This should be fixed via 94ba883 and 71cccc0

@dstogov dstogov closed this as completed Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants