Bug #81634 [NEW]: ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensions with the STATIC_TLS flag
| From: | cataphract@php.net | Date: | Thu, 18 Nov 2021 11:02:42 +0000 |
| Subject: | Bug #81634 [NEW]: ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensions with the STATIC_TLS flag | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-237838@lists.php.net to get a copy of this message | ||
From: cataphract
Operating system: Linux
PHP version: 8.0.12
Package: *General Issues
Bug Type: Bug
Bug description:ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensions with the STATIC_TLS flag
Description:
------------
Starting in PHP 8, defining causes ZEND_ENABLE_STATIC_TSRMLS_CACHE
causes the resulting extension to produce static TLS relocations. The
resulting module will have the STATIC_TLS flag.
Depending on the size of the TLS are of the module and the other
extensions already loaded, this can cause the glibc not to be able to
load the extension, with the error "cannot allocate memory in static TLS
block".
glibc has this comment in the relevant oath:
/* We are trying to perform a static TLS relocation in MAP, but it was
dynamically loaded. This can only work if there is enough surplus
in
the static TLS area already allocated for each running thread... */
This seems to happen even if the macros ZEND_TSRMLS_CACHE_EXTERN/DEFINE
are not used by the extension so as to avoid the TSRM_TLS_MODEL_ATTR
macro. I haven't tracked the exact effect of the
ZEND_TSRMLS_CACHE_EXTERN macro but perhaps it is related to the usage of
SG/PG/EG on the extension.
Test script:
---------------
readelf -d my_extension.so | grep STATIC_TLS
Expected result:
----------------
The STATIC_TLS flags should not be found. IIUC, relocations related to
the initial-exec model (R_X86_64_TPOFF64) should not be found in the
extension.
Actual result:
--------------
The STATIC_TLS flags is found.
--
Edit bug report at https://bugs.php.net/bug.php?id=81634&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81634&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81634&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81634&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81634&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81634&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81634&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81634&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81634&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81634&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81634&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81634&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81634&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81634&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81634&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81634&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81634&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81634&r=mysqlcfg