Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#73470 - [uwsgi-plugin-php] completly broken with php 8.1

Attached to Project: Community Packages
Opened by Damjan Georgievski (damjan) - Sunday, 23 January 2022, 12:54 GMT
Last edited by David Runge (dvzrv) - Tuesday, 01 February 2022, 09:08 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Pierre Schmitz (Pierre)
Sven-Hendrik Haase (Svenstaro)
David Runge (dvzrv)
Architecture x86_64
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

''$ cat /srv/http/index.php''
<code>
<?php
phpinfo();
</code>


''$ uwsgi --plugin 0:php --http-socket :8081 --php-docroot /srv/http/ --php-index index.php''
<code>
*** Starting uWSGI 2.0.20 (64bit) on [Sun Jan 23 13:41:22 2022] ***
compiled with version: 11.1.0 on 04 January 2022 18:16:08
os: Linux-5.16.2-arch1-1 #1 SMP PREEMPT Thu, 20 Jan 2022 16:18:29 +0000
nodename: archless
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 12
current working directory: /home/damjan
detected binary path: /usr/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 111738
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8081 fd 3
PHP document root set to /srv/http
PHP Warning: Missing arginfo for uwsgi_version() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_setprocname() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_worker_id() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_masterpid() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_signal() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_rpc() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_cache_get() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_cache_set() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_cache_update() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_cache_del() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_cache_clear() in Unknown on line 0
PHP Warning: Missing arginfo for uwsgi_cache_exists() in Unknown on line 0
PHP 8.1.1 initialized
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 49992, cores: 1)
PHP Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0
PHP Fatal error: Failed opening required ' ' (include_path='.:') in Unknown on line 0
[pid: 49992|app: -1|req: -1/1] 192.168.17.225 () {32 vars in 532 bytes} [Sun Jan 23 13:41:34 2022] GET / => generated 0 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 103 bytes (0 switches on core 0)
[pid: 49992|app: -1|req: -1/2] 192.168.17.225 () {32 vars in 496 bytes} [Sun Jan 23 13:41:34 2022] GET /favicon.ico => generated 9 bytes in 0 msecs (HTTP/1.1 404) 2 headers in 71 bytes (0 switches on core 0)
PHP Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0
PHP Fatal error: Failed opening required ' ' (include_path='.:') in Unknown on line 0
[pid: 49992|app: -1|req: -1/3] 192.168.17.225 () {32 vars in 550 bytes} [Sun Jan 23 13:41:49 2022] GET /index.php => generated 0 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 103 bytes (0 switches on core 0)
</code>

everything identical but with php7 (''--plugin 0:php7'') works just fine (and it worked with php 8.0).
This task depends upon

Closed by  David Runge (dvzrv)
Tuesday, 01 February 2022, 09:08 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed with uwsgi-plugin-php 2.0.20-5
Comment by Pierre Schmitz (Pierre) - Sunday, 23 January 2022, 16:37 GMT
Applying this patch gets rid of the warnings: https://github.com/unbit/uwsgi/commit/90766833f2bcd2a83039ed4e18501bfb52162e6c

I still fails with the "file not found" error.

EDIT: Very strange. It looks for a file called "hp" in your doc root. If you create such file its content gets executed. I suggest to report it upstream.
Comment by David Runge (dvzrv) - Monday, 24 January 2022, 09:17 GMT
@Pierre: This type of issue is precisely why I would have wanted php 8.1 in testing for a longer time.

Fixing this in a live environment is messy and leads to developer burnout.
Comment by David Runge (dvzrv) - Monday, 24 January 2022, 09:28 GMT
FWIW: There appears to be an upstream issue about this, but so far no movement: https://github.com/unbit/uwsgi/issues/2394
Comment by Pierre Schmitz (Pierre) - Monday, 24 January 2022, 14:30 GMT
This is very unfortunate. Looking into it, I am not sure if waiting would have solved this issue.

It seems the upstream project does not actively track PHP development. While it's great they do CI testing they only run tests on various Python versions: https://github.com/unbit/uwsgi/blob/master/.github/workflows/test.yml There is a compile test (which would not have found this issue) that only checks against PHP 7.2: https://github.com/unbit/uwsgi/blob/master/.github/workflows/compile-test.yml (7.2 is end of live since November 2020)

The issue is they use char instead of zend_string for real_filename?
Comment by David Runge (dvzrv) - Monday, 24 January 2022, 14:46 GMT
> The issue is they use char instead of zend_string for real_filename?

I am not sure, but it looks as if that might lead to an issue such as this, where filenames are weirdly truncated.
If you have a clue how to fix that for the upstream codebase, I'm sure they'd be happy about contributions.

Upstream certainly needs to invest time into automated tests and development of various plugins.
Given that we have close to no documentation on using e.g. php-fpm it's also not super easy to just point at this as a replacement for setups that are covered by uwsgi (see wiki: https://wiki.archlinux.org/title/UWSGI).
Comment by Pierre Schmitz (Pierre) - Monday, 24 January 2022, 15:33 GMT
I did look into it, but this seems to be beyond my knowledge of C and PHP internals.
Comment by slip (slip) - Monday, 24 January 2022, 16:58 GMT
> I am not sure, but it looks as if that might lead to an issue such as this, where filenames are weirdly truncated.

This is what's happening to me. I use uwsgi for Nextcloud and Nextcloud is working, however, it's unreachable and the fatal error is a truncated 'loud/index.php' instead of 'nextcloud/index.php'

Full error -

Jan 23 21:24:53 server uwsgi[81310]: [pid: 81310|app: -1|req: -1/1] 10.0.0.10 () {56 vars in 1015 bytes} [Sun Jan 23 21:24:53 2022] GET / => generated 0 bytes in 1 msecs (HTTP/2.0 500) 2 headers in 103 bytes (0 switches on core 0)
Jan 23 21:24:53 server uwsgi[81310]: PHP Fatal error: Failed opening required 'loud/index.php' (include_path='.:') in Unknown on line 0
Jan 23 21:24:53 server uwsgi[81310]: PHP Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0
Comment by Pierre Schmitz (Pierre) - Tuesday, 25 January 2022, 18:06 GMT
In the meantime the best workaround is probably to use either php7 or migrate to use php-fpm instead of uwsgi.

Not to derail this bug report, but I'd be interested to learn why people choose uwsgi over fpm which is provided by PHP itself.
Comment by Damjan Georgievski (damjan) - Tuesday, 25 January 2022, 18:18 GMT
> but I'd be interested to learn why people choose uwsgi over fpm which is provided by PHP itself.

the thing(s) I like about uwsgi-php is that I can run each PHP web app as it's own service, it's own user (DynamicUser=tru really) and privileges.
also it supported sd_notify long time ago, and has journald specific logging. In some more ambitious projects I do use its internal routing too, and even it's static file server (when uwsgi runs in a container, so nginx can't see the static files). And I can easily have per-service php.ini without loading a global one.

php-fpm on the other hand, mimics the Apache single-root-process that spawns workers which I don't quite like.

There are probably more reasons, but these are the ones I thought of first.

Let's keep this issue open, I might have time to take a look what the underlying issue is.
Comment by Pierre Schmitz (Pierre) - Tuesday, 25 January 2022, 18:40 GMT
Thanks for the hint. root-less fpm and separate users and fpm instances per app can be achieved when involving systemd. But right, this is not builtin and even less documented.
Comment by David Runge (dvzrv) - Tuesday, 01 February 2022, 09:03 GMT
Upstream has implemented a fix with https://github.com/unbit/uwsgi/pull/2400
This is applied with uwsgi-plugin-php 2.0.20-5, now in [community].
Comment by David Runge (dvzrv) - Tuesday, 01 February 2022, 09:06 GMT
In case you have the sufficient resources and/or use uwsgi in a professional context, I would suggest to read this ticket on the health status of the project [1] and to get involved or supply funding for the developers.

[1] https://github.com/unbit/uwsgi/issues/2287

Loading...