diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-03 11:56:55 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-03 12:31:23 +0200 |
commit | 7620ea15807a84e76cb1cb2f9d5234ea787aae2e (patch) | |
tree | 2aa3bbc0ade168c8f07a83eb2b87cbfad194940f /ext/opcache/ZendAccelerator.c | |
parent | c4016ecd446ef26bb3dc77735b6e441e151ea985 (diff) | |
download | php-git-7620ea15807a84e76cb1cb2f9d5234ea787aae2e.tar.gz |
Don't intern compiled_filename
For php-ast interning the file name is an effective memory leak,
see php-ast#134.
I don't think there's any reason to do this. At some point this
was needed due to bugs in the interned string mechanism that
caused issues if the string was later interned, e.g. through a
__FILE__ reference. These issues have since been resolved.
In conjunction with the filenames_table removal in c4016ecd446ef26bb3dc77735b6e441e151ea985
this means that filenames now need to be refcounted like normal
strings. In particular the filename reference in op_arrays and CEs
are refcounted.
Diffstat (limited to 'ext/opcache/ZendAccelerator.c')
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 725b33d913..8683dc106f 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -4528,7 +4528,6 @@ static int accel_preload(const char *config, zend_bool in_child) if (ret == SUCCESS) { zend_persistent_script *script; - zend_string *filename; int ping_auto_globals_mask; int i; zend_class_entry *ce; @@ -4668,7 +4667,7 @@ static int accel_preload(const char *config, zend_bool in_child) script->ping_auto_globals_mask = ping_auto_globals_mask; /* Store all functions and classes in a single pseudo-file */ - filename = zend_string_init("$PRELOAD$", sizeof("$PRELOAD$") - 1, 0); + CG(compiled_filename) = zend_string_init("$PRELOAD$", sizeof("$PRELOAD$") - 1, 0); #if ZEND_USE_ABS_CONST_ADDR init_op_array(&script->script.main_op_array, ZEND_USER_FUNCTION, 1); #else @@ -4690,8 +4689,8 @@ static int accel_preload(const char *config, zend_bool in_child) ZEND_PASS_TWO_UPDATE_CONSTANT(&script->script.main_op_array, script->script.main_op_array.opcodes, script->script.main_op_array.opcodes[0].op1); zend_vm_set_opcode_handler(script->script.main_op_array.opcodes); - script->script.main_op_array.filename = filename; - script->script.filename = zend_string_copy(filename); + script->script.filename = CG(compiled_filename); + CG(compiled_filename) = NULL; script->script.first_early_binding_opline = (uint32_t)-1; @@ -4728,8 +4727,6 @@ static int accel_preload(const char *config, zend_bool in_child) SHM_PROTECT(); HANDLE_UNBLOCK_INTERRUPTIONS(); - zend_string_release(filename); - ZEND_ASSERT(ZCSG(preload_script)->arena_size == 0); preload_load(); |