Skip to content

Commit 3fb0a73

Browse files
Fix memory corruption of INIs in ZTS builds (#3898)
* Fix memory corruption of INIs in ZTS builds The preloading skip was lost during the last refactor; putting it back. * Update zend_abstract_interface/config/config_ini.c * Remove too aggressive assertion --------- Co-authored-by: Florian Engelhardt <[email protected]>
1 parent 27c28e4 commit 3fb0a73

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

zend_abstract_interface/config/config_ini.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void zai_config_ini_rinit(void) {
396396

397397
#if ZTS
398398
// Skip during preloading, in that case EG(ini_directives) is the actual source of truth (NTS-like)
399-
if (env_to_ini_name && !inis_synchronized && zai_config_first_rinit_done) {
399+
if (env_to_ini_name && !inis_synchronized && zai_config_first_rinit_done && !in_startup) {
400400
for (uint16_t i = 0; i < zai_config_memoized_entries_count; ++i) {
401401
zai_config_memoized_entry *memoized = &zai_config_memoized_entries[i];
402402
if (!memoized->original_on_modify) {
@@ -405,6 +405,8 @@ void zai_config_ini_rinit(void) {
405405
zend_ini_entry *source = memoized->ini_entries[n],
406406
*ini = zend_hash_find_ptr(EG(ini_directives), source->name);
407407
// On ZTS INIs must be not shared between threads (otherwise: refcount race conditions). Hence we dup them rather than just copy.
408+
ZEND_ASSERT(ini && source);
409+
ZEND_ASSERT(ini != source && "ZTS INI sync must not run against the global INI table");
408410
if (ini->modified) {
409411
bool identical_orig = ini->orig_value == ini->value;
410412
zend_string_release(ini->orig_value);

0 commit comments

Comments
 (0)