Skip to content

Use an non-interned zend_string for registerExtension on ZTS #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ php:
env:
- V8VER=5.2
- V8VER=5.1
- V8VER=5.2 VALGRIND=1

before_install: make -f Makefile.travis before_install
install: make -f Makefile.travis install
install:
- if [ "$VALGRIND" = 1 ]; then sudo apt-get install -qq valgrind; export TEST_PHP_ARGS="-m"; fi
- make -f Makefile.travis install

script: make -f Makefile.travis test
7 changes: 5 additions & 2 deletions v8js_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ static void v8js_jsext_free_storage(v8js_jsext *jsext) /* {{{ */
v8js_free_ext_strarr(jsext->deps, jsext->deps_count);
}
delete jsext->extension;
// Free the persisted non-interned strings we allocated.
zend_string_release(jsext->name);
zend_string_release(jsext->source);

Expand Down Expand Up @@ -959,8 +960,10 @@ static int v8js_register_extension(zend_string *name, zend_string *source, zval
}

jsext->auto_enable = auto_enable;
jsext->name = zend_string_dup(name, 1);
jsext->source = zend_string_dup(source, 1);
// Allocate a persistent string which will survive until module shutdown on both ZTS(Persistent) and NTS(Not interned, those would be cleaned up)
// (zend_string_dup would return the original interned string, if interned, so we don't use that)
jsext->name = zend_string_init(ZSTR_VAL(name), ZSTR_LEN(name), 1);
jsext->source = zend_string_init(ZSTR_VAL(source), ZSTR_LEN(source), 1);

if (jsext->deps) {
jsext->deps_ht = (HashTable *) malloc(sizeof(HashTable));
Expand Down