com php-src: Fix op_arrays with opcache: sapi/phpdbg/ phpdbg.c sapi/phpdbg/phpdbg.h sapi/phpdbg/phpdbg_list .c sapi/phpdbg/phpdbg_list.h
| From: | Bob Weinand | Date: | Fri, 24 Jul 2015 22:31:05 +0000 |
| Subject: | com php-src: Fix op_arrays with opcache: sapi/phpdbg/ phpdbg.c sapi/phpdbg/phpdbg.h sapi/phpdbg/phpdbg_list .c sapi/phpdbg/phpdbg_list.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88157@lists.php.net to get a copy of this message | ||
Commit: b4c595dd82548575304d3b41b1c9321f50a5fefd
Author: Bob Weinand <bobwei9@hotmail.com> Sat, 25 Jul 2015 00:31:05 +0200
Parents: cf8598593525664d7c66a7998fae68ee9268e60e
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b4c595dd82548575304d3b41b1c9321f50a5fefd
Log:
Fix op_arrays with opcache
Changed paths:
M sapi/phpdbg/phpdbg.c
M sapi/phpdbg/phpdbg.h
M sapi/phpdbg/phpdbg_list.c
M sapi/phpdbg/phpdbg_list.h
Diff:
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 0a84202..a40ab83 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -1756,6 +1756,8 @@ phpdbg_main:
/* Make stdin, stdout and stderr accessible from PHP scripts */
phpdbg_register_file_handles();
+ phpdbg_list_update();
+
if (show_banner && cleaning < 2) {
/* print blurb */
phpdbg_welcome(cleaning == 1);
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index d6e8ddb..ac9e809 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -262,6 +262,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
zend_bool unclean_eval; /* do not check for memory leaks when we needed to
bail out during eval */
zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type);
+ zend_op_array *(*init_compile_file)(zend_file_handle *file_handle, int type);
HashTable file_sources;
FILE *oplog; /* opline log */
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 00788a0..d00f944 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -278,23 +278,52 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
}
dataptr->lines = ++line;
dataptr->line[line] = endptr - data.buf;
- dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line);
+ ret = PHPDBG_G(compile_file)(&fake, type);
+
+ if (ret == NULL) {
+ efree(dataptr);
+ return NULL;
+ }
+
+ dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line);
zend_hash_str_add_ptr(&PHPDBG_G(file_sources), filename, strlen(filename), dataptr);
phpdbg_resolve_pending_file_break(filename);
- ret = PHPDBG_G(compile_file)(&fake, type);
-
fake.opened_path = NULL;
zend_file_handle_dtor(&fake);
+ return ret;
+}
+
+zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
+ char *filename = (char *)(file->opened_path ? ZSTR_VAL(file->opened_path) :
file->filename);
+ char resolved_path_buf[MAXPATHLEN];
+ zend_op_array *ret;
+ phpdbg_file_source *dataptr;
+
+ if (VCWD_REALPATH(filename, resolved_path_buf)) {
+ filename = resolved_path_buf;
+ }
+
+ ret = PHPDBG_G(init_compile_file)(file, type);
+
+ if (ret == NULL) {
+ return NULL;
+ }
+
+ dataptr = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), filename, strlen(filename));
+ ZEND_ASSERT(dataptr != NULL);
+
dataptr->op_array = ret;
+ dataptr->destroy_op_array = 1;
if (dataptr->op_array) {
if (dataptr->op_array->refcount) {
++*dataptr->op_array->refcount;
} else {
dataptr->op_array->refcount = emalloc(sizeof(uint32_t));
*dataptr->op_array->refcount = 2;
+ dataptr->destroy_op_array = 0;
}
}
@@ -313,7 +342,7 @@ void phpdbg_free_file_source(zval *zv) {
efree(data->buf);
}
- if (destroy_op_array(data->op_array)) {
+ if (!data->destroy_op_array || destroy_op_array(data->op_array)) {
efree(data->op_array);
}
@@ -325,3 +354,8 @@ void phpdbg_init_list(void) {
zend_hash_init(&PHPDBG_G(file_sources), 1, NULL, (dtor_func_t) phpdbg_free_file_source, 0);
zend_compile_file = phpdbg_compile_file;
}
+
+void phpdbg_list_update(void) {
+ PHPDBG_G(init_compile_file) = zend_compile_file;
+ zend_compile_file = phpdbg_init_compile_file;
+}
diff --git a/sapi/phpdbg/phpdbg_list.h b/sapi/phpdbg/phpdbg_list.h
index bfaef06..8530ea2 100644
--- a/sapi/phpdbg/phpdbg_list.h
+++ b/sapi/phpdbg/phpdbg_list.h
@@ -39,6 +39,7 @@ void phpdbg_list_file(zend_string *, uint, int, uint);
extern const phpdbg_command_t phpdbg_list_commands[];
void phpdbg_init_list(void);
+void phpdbg_list_update(void);
typedef struct {
char *filename;
@@ -48,6 +49,7 @@ typedef struct {
void *map;
#endif
zend_op_array *op_array;
+ zend_bool destroy_op_array;
uint lines;
uint line[1];
} phpdbg_file_source;