ngx-php icon indicating copy to clipboard operation
ngx-php copied to clipboard

Error: memory entry 0 is not directly addressable

Open jeijei4 opened this issue 3 years ago • 14 comments

https://github.com/rryqszq4/ngx-php/blob/73ef8b155d3182fa1a9514761afe1f10cd0bd48f/src/ngx_http_php8_zend_uthread.c#L44

OS: Fedora 35 php: 8.1 remi (php81) nginx: 1.21.5

Error:

In the file included from /opt/remi/php81/root/usr/include/php/Zend/zend_dtrace_gen.h:10,
from /opt/remi/php81/root/usr/include/php/Zend/zend_dtrace.h:38,
from /ngx_php7/src/ngx_http_php8_zend_uthread.c:36:
/ngx_php7/src/ngx_http_php8_zend_uthread.c: In the function ‘ngx_http_php_zend_throw_exception_internal’:
/opt/remi/php81/root/usr/include/php/Zend/zend_dtrace_gen.h:32:1: error: memory entry 0 is not directly addressable
   32 | DTRACE_PROBE1 (php, exception__thrown, arg1)
      | ^ ~~~~~~~~~~~~
/ngx_php7/src/ngx_http_php8_zend_uthread.c:436:13: note: macro expansion ‘DTRACE_EXCEPTION_THROWN’
  436 | DTRACE_EXCEPTION_THROWN (ZSTR_VAL (exception-> ce-> name));
      | ^ ~~~~~~~~~~~~~~~~~~~~~~
/opt/remi/php81/root/usr/include/php/Zend/zend_dtrace_gen.h:32:1: error: memory entry 0 is not directly addressable
   32 | DTRACE_PROBE1 (php, exception__thrown, arg1)
      | ^ ~~~~~~~~~~~~
/ngx_php7/src/ngx_http_php8_zend_uthread.c:438:13: note: macro expansion ‘DTRACE_EXCEPTION_THROWN’
  438 | DTRACE_EXCEPTION_THROWN (NULL);
      | ^ ~~~~~~~~~~~~~~~~~~~~~~

Code:


export NGINX_VER=1.21.5 && export OPENSSL_VER=3.0.1 && export HEADERMOD_VER=0.33 && export PHP_VERSION=php81 && export PHP_CONFIG=/opt/remi/${PHP_VERSION}/root/usr/bin/php-config && export PHP_BIN=/opt/remi/${PHP_VERSION}/root/usr/bin && export PHP_INC=/opt/remi/${PHP_VERSION}/root/usr/include/php && export PHP_LIB=/opt/remi/${PHP_VERSION}/root/usr/lib64

mkdir -p /usr/local/src/nginx/modules

cd /usr/local/src/nginx/modules
git clone https://github.com/rryqszq4/ngx_php7.git && wget https://github.com/openresty/headers-more-nginx-module/archive/v${HEADERMOD_VER}.tar.gz && tar xaf v${HEADERMOD_VER}.tar.gz && git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module && wget https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz && tar xaf openssl-${OPENSSL_VER}.tar.gz && cd openssl-${OPENSSL_VER}
./config

cd /usr/local/src/nginx/
wget -qO- https://nginx.org/download/nginx-${NGINX_VER}.tar.gz | tar zxf -
cd nginx-${NGINX_VER}

wget https://raw.githubusercontent.com/nginx-modules/ngx_http_tls_dyn_size/master/nginx__dynamic_tls_records_1.17.7%2B.patch -O tcp-tls.patch
patch -p1 <tcp-tls.patch

wget https://raw.githubusercontent.com/hakasenyang/openssl-patch/master/nginx_hpack_push_1.15.3.patch -O nginx_http2_hpack.patch
patch -p1 <nginx_http2_hpack.patch

./configure --user=nginx --group=nginx --prefix=/etc/nginx --with-pcre-jit --with-mail --with-debug --with-file-aio --with-mail_ssl_module --with-stream --with-stream_ssl_module --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --with-cc-opt=-Wno-deprecated-declarations --with-cc-opt=-Wno-ignored-qualifiers --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_mp4_module --with-http_auth_request_module --with-http_slice_module --with-http_stub_status_module --with-http_realip_module --with-http_sub_module --add-module=/usr/local/src/nginx/modules/headers-more-nginx-module-${HEADERMOD_VER} --add-module=/usr/local/src/nginx/modules/ngx_http_substitutions_filter_module --with-openssl=/usr/local/src/nginx/modules/openssl-${OPENSSL_VER} --with-http_v2_hpack_enc --with-ld-opt="-Wl,-rpath,$PHP_LIB" --add-module=/usr/local/src/nginx/modules/ngx_php7/third_party/ngx_devel_kit --add-module=/usr/local/src/nginx/modules/ngx_php7

make -j "$(nproc)"
make install

jeijei4 avatar Jan 04 '22 23:01 jeijei4

@jeijei4 Thanks report ! Need more time to research~

rryqszq4 avatar Jan 12 '22 10:01 rryqszq4

The same problem using Ubuntu 21.04 or 21.10.

But it's working without problems with Ubuntu 20.04.

FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php > /dev/null
RUN apt-get update -yqq > /dev/null && apt-get upgrade -yqq > /dev/null && \
    apt-get install -yqq wget git unzip libxml2-dev cmake make systemtap-sdt-dev \
                    zlib1g-dev libpcre3-dev libargon2-0-dev libsodium-dev \
                    php8.1-cli php8.1-dev libphp8.1-embed php8.1-mysql nginx > /dev/null
ADD ./ ./

ENV NGINX_VERSION 1.21.6

RUN git clone -b v0.0.26 --single-branch --depth 1 https://github.com/rryqszq4/ngx_php7.git > /dev/null

RUN wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
    tar -zxf nginx-${NGINX_VERSION}.tar.gz && \
    cd nginx-${NGINX_VERSION} && \
    export PHP_LIB=/usr/lib && \ 
    bash ./configure --user=www --group=www \
            --prefix=/nginx \
            --with-ld-opt="-Wl,-rpath,$PHP_LIB" \
            --add-module=/ngx_php7/third_party/ngx_devel_kit \
            --add-module=/ngx_php7 > /dev/null && \
    make > /dev/null && make install > /dev/null

EXPOSE 8080

CMD /nginx/sbin/nginx -c /deploy/nginx_default.conf 

If we change to 21.04 or 21.10

php-ngx: In file included from /usr/include/php/20210902/Zend/zend_dtrace_gen.h:10,
php-ngx:                  from /usr/include/php/20210902/Zend/zend_dtrace.h:38,                                                            
php-ngx:                  from /ngx_php7/src/ngx_http_php8_zend_uthread.c:36:
php-ngx: /ngx_php7/src/ngx_http_php8_zend_uthread.c: In function 'ngx_http_php_zend_throw_exception_internal':
php-ngx: /usr/include/php/20210902/Zend/zend_dtrace_gen.h:32:1: error: memory input 0 is not directly addressable
php-ngx:    32 | DTRACE_PROBE1 (php, exception__thrown, arg1)                                                                              
php-ngx:       | ^~~~~~~~~~~~~
php-ngx: /ngx_php7/src/ngx_http_php8_zend_uthread.c:436:13: note: in expansion of macro 'DTRACE_EXCEPTION_THROWN'
php-ngx:   436 |             DTRACE_EXCEPTION_THROWN(ZSTR_VAL(exception->ce->name));
php-ngx:       |             ^~~~~~~~~~~~~~~~~~~~~~~
php-ngx: /usr/include/php/20210902/Zend/zend_dtrace_gen.h:32:1: error: memory input 0 is not directly addressable
php-ngx:    32 | DTRACE_PROBE1 (php, exception__thrown, arg1)                                                                              
php-ngx:       | ^~~~~~~~~~~~~
php-ngx: /ngx_php7/src/ngx_http_php8_zend_uthread.c:438:13: note: in expansion of macro 'DTRACE_EXCEPTION_THROWN'
php-ngx:   438 |             DTRACE_EXCEPTION_THROWN(NULL);
php-ngx:       |             ^~~~~~~~~~~~~~~~~~~~~~~
php-ngx: make[1]: *** [objs/Makefile:1328: objs/addon/src/ngx_http_php8_zend_uthread.o] Error 1
php-ngx: make: *** [Makefile:10: build] Error 2                                                                                            
php-ngx: Removing intermediate container b510eb640248                                                                                      
php-ngx: Docker build failed; terminating

The research will be easier :)

joanhey avatar Feb 04 '22 16:02 joanhey

got same problem on debian 11

theraw avatar Mar 28 '22 03:03 theraw

@rryqszq4 are you OK ?

Now fail with, ubuntu 20.04 and php 8.2.

joanhey avatar Nov 16 '22 00:11 joanhey

image

joanhey avatar Nov 16 '22 00:11 joanhey

Now it's working with PHP 8.2.

I added the tests with Ubuntu 22.04, so we will try to fix it. The error in the tests is the same https://github.com/rryqszq4/ngx-php/actions/runs/4677281560/jobs/8284601262

joanhey avatar Apr 12 '23 18:04 joanhey

~I think that I found the problem. And it's very simple.~

~All PHP versions in Ubuntu 22.04 don't use --enable-dtrace. So we need to validate it first, or remove the dtrace code.~

I can't find the problem for now.

joanhey avatar Apr 12 '23 20:04 joanhey

We found the bug, we are deciding the best way to implement the fix.

joanhey avatar Apr 16 '23 18:04 joanhey

I'm having the same issue with PHP 8.2.7, Nginx 1.25.1 and Linux Mint 21 (Ubuntu 22.04)

osbre avatar Jun 17 '23 13:06 osbre

Please could you try with the development branch. Theoretically is working, but will be better to have feedback from the users. But still not send the changes to the master branch.

joanhey avatar Jun 17 '23 14:06 joanhey

It's working, but we need to create a new version, to download easily. The next branch, it is working with new OS versions.

Ping @rryqszq4

joanhey avatar Nov 30 '23 13:11 joanhey

Also working with PHP 8.3. Only waiting for new ngx-php version release.

joanhey avatar Nov 30 '23 17:11 joanhey

Ubuntu 22.04, Nginx 1.25.3 and PHP 8.3. Nginx 1.25.x support http3.

https://github.com/TechEmpower/FrameworkBenchmarks/pull/8614

joanhey avatar Dec 03 '23 17:12 joanhey

Fixed https://github.com/rryqszq4/ngx-php/releases/tag/v0.0.28

joanhey avatar Dec 05 '23 14:12 joanhey