Bug #80814 [Com]: threaded mod_php won't load: No space available for static Thread Local Storage

From: Date: Fri, 25 Feb 2022 14:06:49 +0000
Subject: Bug #80814 [Com]: threaded mod_php won't load: No space available for static Thread Local Storage
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240028@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80814&edit=1 ID: 80814 Comment by: ct at flyingcircus dot io Reported by: theultramage at gmail dot com Summary: threaded mod_php won't load: No space available for static Thread Local Storage Status: Closed Type: Bug Package: Dynamic loading Operating System: FreeBSD 12.2 PHP Version: 8.0.2 Assigned To: dmitry Block user comment: N Private report: N New Comment: So I tried doing the glibc.rtld.optional_static_tls dance and I can now see that there's some leakage going on. When I increase the static tls I get more reloads, but at some point it fails: tls -> breaks on reload # 512 -> 3 1024 -> 4 2048 -> 6 4096 -> 11 8192 -> 20 16384 -> 38 32768 -> 75 One more data point: when I run PHP without _ANY_ modules then I can easily reload Apache 1000+ times without any issues. So it doesn't seem to be a purely Apache-driven issue, but maybe an Apache bug that only manifests in a specific combination with certain PHP modules ... o_O Previous Comments: ------------------------------------------------------------------------ [2022-02-25 13:50:20] ct at flyingcircus dot io I am experiencing this as well with Apache 2.4.52 and PHP 8.0.16 on Linux. I can trigger this reliably after ~3-7 Apache reloads. The minimal set of modules that will fail is when enabling imap + zlib. This then causes Apache to completely fail at crash (which is actually a favourable outcome as it can then be restarted). Other combinations (like imagick + zlib) cause more tricky errors where the reload will fail but Apache keeps running and then stuff is just broken. ------------------------------------------------------------------------ [2022-01-10 07:17:07] dmitry@php.net @alien I think, the problem may occur because Apache loads few modules that use static TLS and the required amount exceeds the available size. (It may be increased. See https://www.gnu.org/software/libc/manual/html_node/Dynamic-Linking-Tunables.html). But this would cause failure on each restart. May be the problem is somehow related to graceful restart. May be some Apache modules, or shared libraries were updated between restarts and this somehow triggered the failure. Let me know, if you find more info. ------------------------------------------------------------------------ [2022-01-02 10:17:22] alien at rmail dot be I'm on linux with version 8.0.5 and I've noticed that logrotate, which does a httpd reload, which is a graceful restart, cannot load modphp (sometimes), due to what appears to be exactly this problem... maybe not only freeBSD has trouble with this kind of thing... The problem is that i had it 1st of Nov and 1st of Jan this year, but not on december? so it does not happen always, not easily reproducable, but it's still twice: [Sat Jan 01 04:02:01.476121 2022] [mpm_prefork:notice] [pid 1060] AH00171: Graceful restart requested, doing restart httpd: Syntax error on line 54 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/conf/modules.d/70_mod_php.conf: Cannot load modules/mod_php.so into server: /etc/httpd/modules/mod_php.so: cannot allocate memory in static TLS block ------------------------------------------------------------------------ [2021-03-10 13:04:47] dmitry@php.net Automatic comment on behalf of dmitry@zend.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=3b377b51a22681f4594f8eb55e6de25ea01204c1 Log: Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space available for static Thread Local Storage) ------------------------------------------------------------------------ [2021-03-09 07:44:11] dmitry@php.net The code in TSRM.c allows to use the most efficient "local-exec" access model from JIT-ed code. If tsrm_get_ls_cache_tcb_offset() returns 0, zend_jit_setup() switches JIT code-generator to less efficient access method. This works fine on Linux with both GCC and CLANG. I didn't get, if you tested the patch, and it's good enough, to fix the problem on FreeBSD. If it misses something (e.g. i386 support) please extend it. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=80814 -- Edit this bug report at https://bugs.php.net/bug.php?id=80814&edit=1

« previous php.bugs (#240028) next »