Bug 250652 - www/mod_php80 LINKTHR build breaks apache
Summary: www/mod_php80 LINKTHR build breaks apache
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Torsten Zuehlsdorff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-26 20:17 UTC by Jack
Modified: 2021-06-04 20:50 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (tz)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jack 2020-10-26 20:17:34 UTC
When mod_php80 is built with LINKTHR, apache fails to load libphp.so with the following error

httpd: Syntax error on line 152 of /usr/local/etc/apache24/httpd.conf: Cannot load libexec/apache24/libphp.so into server: /usr/local/libexec/apache24/libphp.so: No space available for static Thread Local Storage
Comment 1 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2020-10-26 21:57:25 UTC
Hi Jack,

this seems to be a reoccurring problem, but its not really a PHP bug.

A common solutions seems to be:
* Use Apache with MPM_PREFORK mode
* Turn off LINKTHR and ZTS

I stopped using Apache years ago in favor of nginx. So i can't really help with this one.

Greetings,
Torsten
Comment 2 rainer 2021-01-29 11:10:35 UTC
I also get this, from php-fpm itself.

(f-hosting <etc>) 0 # /usr/local/php80/etc/rc.d/php-fpm start
Performing sanity check on php-fpm configuration:
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library 'imap.so' (tried: /usr/local/php80/lib/php/20200930-zts/imap.so (/usr/local/php80/lib/php/20200930-zts/imap.so: No space available for static Thread Local Storage), /usr/local/php80/lib/php/20200930-zts/imap.so.so (Cannot open &quot;/usr/local/php80/lib/php/20200930-zts/imap.so.so&quot;)) in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/local/php80/lib/php/20200930-zts/pdo_mysql.so (/usr/local/php80/lib/php/20200930-zts/pdo_mysql.so: No space available for static Thread Local Storage), /usr/local/php80/lib/php/20200930-zts/pdo_mysql.so.so (Cannot open &quot;/usr/local/php80/lib/php/20200930-zts/pdo_mysql.so.so&quot;)) in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Missing arginfo for Imagick::__tostring() in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Missing arginfo for Imagick::getimagehistogram() in <b>Unknown</b> on line <b>0</b><br />
[29-Jan-2021 10:47:18] NOTICE: configuration file /usr/local/php80/etc/php-fpm.conf test is successful

Starting php_fpm.
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library 'imap.so' (tried: /usr/local/php80/lib/php/20200930-zts/imap.so (/usr/local/php80/lib/php/20200930-zts/imap.so: No space available for static Thread Local Storage), /usr/local/php80/lib/php/20200930-zts/imap.so.so (Cannot open &quot;/usr/local/php80/lib/php/20200930-zts/imap.so.so&quot;)) in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/local/php80/lib/php/20200930-zts/pdo_mysql.so (/usr/local/php80/lib/php/20200930-zts/pdo_mysql.so: No space available for static Thread Local Storage), /usr/local/php80/lib/php/20200930-zts/pdo_mysql.so.so (Cannot open &quot;/usr/local/php80/lib/php/20200930-zts/pdo_mysql.so.so&quot;)) in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Missing arginfo for Imagick::__tostring() in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Missing arginfo for Imagick::getimagehistogram() in <b>Unknown</b> on line <b>0</b><br />


Note that I build php80 with a hack so that it installs into /usr/local/php80 in order for me to be able to run all php versions in parallel.


# PHP Makefile arm twisting follows.
p_PHP_FLAVORS=php73 php74 php80
p_GETFLAVOR=echo $$FLAVOR
p_FLAVOR=${p_GETFLAVOR:sh}

.for port in ${p_PHP_FLAVORS}

# Easy part. If your current directory begins with what's in PHP_ALT, you need these variables
.if ${.CURDIR:M*/ports/*/${port}*}
PREFIX=/usr/local/${port}
PHPBASE=/usr/local/${port}
DISABLE_VULNERABILITIES=yes
.info set by CURDIR: ${.CURDIR} -- sets PREFIX: ${PREFIX} and PHPBASE: ${PHPBASE}
.endif

# Harder part, if we detect the flavor is set up via shell environment, you need these variables
.if ${p_FLAVOR} == ${port}
PREFIX=/usr/local/${port}
PHPBASE=/usr/local/${port}
DISABLE_VULNERABILITIES=yes
.info set by FLAVOR ${p_FLAVOR} -- sets PREFIX: ${PREFIX} and PHPBASE: ${PHPBASE}
.endif

.endfor



root@bsd1-build-prod:/usr/local/etc/poudriere.d # more 12_2-amd64-2021Q1-exp-unified-options/lang_php80/options 
# This file is auto-generated by 'make config'.
# Options for php80-8.0.0.r2_1
_OPTIONS_READ=php80-8.0.0.r2_1
_FILE_COMPLETE_OPTIONS_LIST=CLI CGI FPM EMBED PHPDBG DEBUG DTRACE IPV6 MYSQLND LINKTHR ZTS
OPTIONS_FILE_SET+=CLI
OPTIONS_FILE_SET+=CGI
OPTIONS_FILE_SET+=FPM
OPTIONS_FILE_SET+=EMBED
OPTIONS_FILE_UNSET+=PHPDBG
OPTIONS_FILE_UNSET+=DEBUG
OPTIONS_FILE_SET+=DTRACE
OPTIONS_FILE_SET+=IPV6
OPTIONS_FILE_SET+=MYSQLND
OPTIONS_FILE_SET+=LINKTHR
OPTIONS_FILE_SET+=ZTS

I don't use mod_php.


PHP itself seems to work.


I don't really need imap, but pdo_mysql is pdo_mysql is pretty much a given.
Comment 3 Markus Kohlmeyer 2021-02-14 13:58:12 UTC
This is not a bug in PHP, it is a bug in rtld (RTLD_STATIC_TLS_EXTRA is too small).
See also: http://lists.dragonflybsd.org/pipermail/bugs/2013-June/311813.html


My current workaround looks like this:

cd /usr/src
make clean
chflags -R noschg /usr/obj/*
rm -rf /usr/obj/*
svnlite update
cp -a /usr/src/libexec/rtld-elf/rtld.h /root/patches/rtld.h
sed -E -e '/RTLD_STATIC_TLS_EXTRA/ s/128/1280/g' -i '' /usr/src/libexec/rtld-elf/rtld.h
/usr/src/usr.sbin/mergemaster/mergemaster.sh -p
make -j4 buildworld
make -j4 KERNCONF=GENERIC buildkernel
make KERNCONF=GENERIC INSTALLKERNEL=GENERIC INSTKERNNAME=GENERIC installkernel
make installworld
/usr/sbin/mergemaster -iFU --run-updates=always
cp -a /root/patches/rtld.h /usr/src/libexec/rtld-elf/rtld.h
make delete-old -DBATCH_DELETE_OLD_FILES
make delete-old-libs -DBATCH_DELETE_OLD_FILES
shutdown -r now
Comment 4 Markus Kohlmeyer 2021-03-03 13:48:00 UTC
See also: https://bugs.php.net/bug.php?id=80814
Comment 5 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2021-03-04 20:05:44 UTC
Thank you very much for bringing this up! Hopefully, this issue will be fixed soon. :)

If there is a patch before the next release I will happily apply it until the release is done!

Thank you!
Torsten
Comment 6 Marek Zarychta 2021-04-02 18:32:50 UTC
It looks like the patch[1] solves the issue for me (running PHP-FPM with Nginx). This has already been fixed upstream[2] and upcoming 8.0.4 will again work fine built with ZTS.

[1] https://gist.github.com/dstogov/c7c01283766376478b5f7073c1a432a9
[2] http://git.php.net/?p=php-src.git;a=commit;h=3b377b51a22681f4594f8eb55e6de25ea01204c1
Comment 7 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2021-06-03 11:20:19 UTC
Since 8.0.4 was already released: is the issue still gone? :)
Comment 8 Jack 2021-06-04 05:46:10 UTC
seems to be ok now.
Comment 9 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2021-06-04 20:50:23 UTC
Great, happy to hear :)

In this case I close the issue!

Thank you!