Skip to content

Commit 368958b

Browse files
committed
Fixed bug #73983 crash on finish work with phar in cli + opcache
The file_cache_only option causes the storage to be per process, furthermore the arena is destroyed per request. Thus, zend_string's can't survive between request and the permanent flag should not be set. This is already done with the file cache part, but the persistency part is used in various scenarios and should respect this case as well. In this particular bug, the pcre pattern cache needs to survive between requests and uses pattern strings as hash keys. One more case relevant here would be various situations where the flow disables the use of shared memory.
1 parent dd227c2 commit 368958b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ext/opcache/zend_persist.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
#define zend_accel_memdup(p, size) \
3434
_zend_shared_memdup((void*)p, size, 0)
3535

36+
#ifdef HAVE_OPCACHE_FILE_CACHE
37+
#define zend_set_str_gc_flags(str) do { \
38+
if (ZCG(accel_directives).file_cache_only) { \
39+
GC_FLAGS(str) = IS_STR_INTERNED; \
40+
} else { \
41+
GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \
42+
} \
43+
} while (0)
44+
#else
45+
#define zend_set_str_gc_flags(str) GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT
46+
#endif
47+
3648
#define zend_accel_store_string(str) do { \
3749
zend_string *new_str = zend_shared_alloc_get_xlat_entry(str); \
3850
if (new_str) { \
@@ -43,13 +55,13 @@
4355
zend_string_release(str); \
4456
str = new_str; \
4557
zend_string_hash_val(str); \
46-
GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \
58+
zend_set_str_gc_flags(str); \
4759
} \
4860
} while (0)
4961
#define zend_accel_memdup_string(str) do { \
5062
str = zend_accel_memdup(str, _ZSTR_STRUCT_SIZE(ZSTR_LEN(str))); \
5163
zend_string_hash_val(str); \
52-
GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \
64+
zend_set_str_gc_flags(str); \
5365
} while (0)
5466
#define zend_accel_store_interned_string(str) do { \
5567
if (!IS_ACCEL_INTERNED(str)) { \

0 commit comments

Comments
 (0)