Open TysonAndre opened 4 years ago
https://github.com/phpv8/v8js/blob/461230be276dc423d8eebf0c9ea769c71d47b7f6/v8js_class.cc#L793-L798
E.g. the helper returns s
, even if s
was a temporary interned string (allocated with emalloc)
static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool persistent)
{
if (ZSTR_IS_INTERNED(s)) {
return s;
} else {
return zend_string_init(ZSTR_VAL(s), ZSTR_LEN(s), persistent);
}
}
Related to #255 and #247
I stopped using registerExtension, but I think there might be one more registerExtension bug anyway, or even non-obvious bugs.
Motivation for suggesting switching all uses of zend_string_dup/zend_string_copy to zend_string_init() instead
One use from registerExtension with an array of deps seems like it might also be a problem for non-ZTS builds.
Because of that, zend_persistent_zval_dup should probably use zend_string_init instead. zend_string_dup() will return the original pointer for interned strings (e.g. in php 7.2)
Context for why I'm looking at string copying in V8js (if anyone has similar issues): I'm seeing a segfault in zend_interned_string_find_permanent in long-running httpd processes for a fraction of apache restarts (if I read the instruction pointer correctly).
zend_interned_string_find_permanent seems like it would only get called by opcache in php 7.2. The line it crashes on suggests that the pointer to the zend_string that is being looked up was corrupted.
EDIT: I obtained a core dump. I was mistaken about what called zend_interned_string_find_permanent(). The source before signal_handler can vary (memcached, curl, reading files, etc), but it's just any point when signal_handler can get called for the httpd stop.
For
gdb /path/to/libphp7.so path/to/core_dump
EDIT: The larger problem is that this is a hard restart instead of a graceful restart, so the details of shutdown are less important.