When extension is compiled in ZTS mode as a dynamic library both the extension and the php executable have their own copy of global thread-local variable _tsrm_ls_cache (a.k.a TSRMLS_CACHE).
When extension is compiled with define ZEND_ENABLE_STATIC_TSRMLS_CACHE (which is non-configurable and enabled by default in the build system) the extension uses that variable directly instead of going through tsrm_get_ls_cache() function, so it is important that both copies stay synchronized.
If they are not kept in sync then extension may use it own copy which is only initialized to NULL and crash on accessing its module global.
This synchronization should be done on each request as different requests may be handled in different (new) threads (e.g. in Apache's mod_php when a threaded MPM is used).
We also do this in MINIT_FUNCTION just in case.
When extension is compiled in ZTS mode as a dynamic library both the extension and the php executable have their own copy of global thread-local variable
_tsrm_ls_cache
(a.k.aTSRMLS_CACHE
). When extension is compiled with defineZEND_ENABLE_STATIC_TSRMLS_CACHE
(which is non-configurable and enabled by default in the build system) the extension uses that variable directly instead of going throughtsrm_get_ls_cache()
function, so it is important that both copies stay synchronized. If they are not kept in sync then extension may use it own copy which is only initialized toNULL
and crash on accessing its module global.This synchronization should be done on each request as different requests may be handled in different (new) threads (e.g. in Apache's mod_php when a threaded MPM is used). We also do this in
MINIT_FUNCTION
just in case.Fixes: #11