Bug #81634 [Asn->Csd]: ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensions with the STATIC_TLS flag

From: Date: Wed, 24 Nov 2021 17:48:54 +0000
Subject: Bug #81634 [Asn->Csd]: ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensions with the STATIC_TLS flag
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237970@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81634&edit=1 ID: 81634 Updated by: git@php.net Reported by: cataphract@php.net Summary: ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensions with the STATIC_TLS flag -Status: Assigned +Status: Closed Type: Bug Package: *General Issues Operating System: Linux PHP Version: 8.0.12 Assigned To: dmitry Block user comment: N Private report: N New Comment: Automatic comment on behalf of dstogov Revision: https://github.com/php/php-src/commit/72f8dbb31295e4e5633a9033c6d91a45d102c485 Log: Fixed bug #81634 (ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensionswith the STATIC_TLS flag) Previous Comments: ------------------------------------------------------------------------ [2021-11-18 14:03:34] dmitry@php.net Could you please check if https://github.com/php/php-src/pull/7664 fixes the problem for master branch. I'm not sure if we will able to commit the fix into PHP-8.0 and PHP-8.1 brunches. ------------------------------------------------------------------------ [2021-11-18 11:02:42] cataphract@php.net 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 this bug report at https://bugs.php.net/bug.php?id=81634&edit=1

« previous php.bugs (#237970) next »