summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-05-27 16:36:15 +0800
committerXinchen Hui <laruence@gmail.com>2015-05-27 16:36:15 +0800
commit90df7e75e6b1ca301d053cbe6d1dee66c586ecb8 (patch)
tree6a67cd0bbfe9f85253c59d695c42c119f3978c7a
parentf972e219e477fa1f4137de2de24e05c0f5c515e1 (diff)
parentf68dc94aa727085040650b4c9354672f2f62ee6a (diff)
downloadphp-git-90df7e75e6b1ca301d053cbe6d1dee66c586ecb8.tar.gz
Merge branch 'master' into merge-fastcgi
Conflicts: sapi/fpm/fpm/fpm_main.c
-rw-r--r--Makefile.global15
-rw-r--r--Zend/tests/return_types/028.phpt20
-rw-r--r--Zend/zend_language_parser.y4
-rw-r--r--Zend/zend_vm_def.h4
-rw-r--r--Zend/zend_vm_execute.h20
-rw-r--r--configure.in4
-rw-r--r--ext/phar/tests/bug69453.phpt6
-rw-r--r--sapi/fpm/fpm/fpm_main.c2
-rw-r--r--sapi/phpdbg/phpdbg_io.c10
-rw-r--r--sapi/phpdbg/phpdbg_print.c8
-rw-r--r--sapi/phpdbg/phpdbg_utils.c2
11 files changed, 80 insertions, 15 deletions
diff --git a/Makefile.global b/Makefile.global
index f833efa5e7..c571f3455d 100644
--- a/Makefile.global
+++ b/Makefile.global
@@ -130,5 +130,18 @@ distclean: clean
fi
$(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f
-.PHONY: all clean install distclean test
+prof-gen:
+ CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-generate all
+
+prof-clean:
+ find . -name \*.lo -o -name \*.o | xargs rm -f
+ find . -name \*.la -o -name \*.a | xargs rm -f
+ find . -name \*.so | xargs rm -f
+ rm -f libphp$(PHP_MAJOR_VERSION).la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_MILTER_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
+
+prof-use:
+ CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
+
+
+.PHONY: all clean install distclean test prof-gen prof-clean prof-use
.NOEXPORT:
diff --git a/Zend/tests/return_types/028.phpt b/Zend/tests/return_types/028.phpt
new file mode 100644
index 0000000000..d820b25b0e
--- /dev/null
+++ b/Zend/tests/return_types/028.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Memory leak when returning TMP/VAR with wrong return type
+--FILE--
+<?php
+
+function foo(): stdClass {
+ $a = new stdClass;
+ $b = [];
+ return [$a, $b];
+}
+
+try {
+ foo();
+} catch (BaseException $e) {
+ print $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Return value of foo() must be an instance of stdClass, array returned in %s on line %d
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 9f61fabe35..9612324eac 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -80,7 +80,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%right T_POW
%right '['
%nonassoc T_NEW T_CLONE
-%left "if_without_else"
+%left T_NOELSE
%left T_ELSEIF
%left T_ELSE
%left T_ENDIF
@@ -579,7 +579,7 @@ if_stmt_without_else:
;
if_stmt:
- if_stmt_without_else %prec "if_without_else" { $$ = $1; }
+ if_stmt_without_else %prec T_NOELSE { $$ = $1; }
| if_stmt_without_else T_ELSE statement
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_IF_ELEM, NULL, $3)); }
;
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index efbb081922..c71fbc9734 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -3909,6 +3909,10 @@ ZEND_VM_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV, UNUSED)
}
}
zend_verify_return_type(EX(func), retval_ptr);
+
+ if (UNEXPECTED(EG(exception) != NULL)) {
+ FREE_OP1();
+ }
#endif
}
CHECK_EXCEPTION();
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index cd95564219..a38d7db860 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -7815,6 +7815,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CONST_
}
}
zend_verify_return_type(EX(func), retval_ptr);
+
+ if (UNEXPECTED(EG(exception) != NULL)) {
+
+ }
#endif
}
CHECK_EXCEPTION();
@@ -13437,6 +13441,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_TMP_UN
}
}
zend_verify_return_type(EX(func), retval_ptr);
+
+ if (UNEXPECTED(EG(exception) != NULL)) {
+ zval_ptr_dtor_nogc(free_op1);
+ }
#endif
}
CHECK_EXCEPTION();
@@ -19195,6 +19203,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_VAR_UN
}
}
zend_verify_return_type(EX(func), retval_ptr);
+
+ if (UNEXPECTED(EG(exception) != NULL)) {
+ zval_ptr_dtor_nogc(free_op1);
+ }
#endif
}
CHECK_EXCEPTION();
@@ -25140,6 +25152,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_UNUSED
}
}
zend_verify_return_type(EX(func), retval_ptr);
+
+ if (UNEXPECTED(EG(exception) != NULL)) {
+
+ }
#endif
}
CHECK_EXCEPTION();
@@ -34786,6 +34802,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_VERIFY_RETURN_TYPE_SPEC_CV_UNU
}
}
zend_verify_return_type(EX(func), retval_ptr);
+
+ if (UNEXPECTED(EG(exception) != NULL)) {
+
+ }
#endif
}
CHECK_EXCEPTION();
diff --git a/configure.in b/configure.in
index f24f8eaeda..b70f024252 100644
--- a/configure.in
+++ b/configure.in
@@ -1436,10 +1436,10 @@ CC=$old_CC
PHP_CONFIGURE_PART(Generating files)
CXXFLAGS_CLEAN=$CXXFLAGS
-CFLAGS_CLEAN=$CFLAGS
+CFLAGS_CLEAN="$CFLAGS \$(PROF_FLAGS)"
CFLAGS="\$(CFLAGS_CLEAN) $standard_libtool_flag"
INLINE_CFLAGS="$INLINE_CFLAGS $standard_libtool_flag"
-CXXFLAGS="$CXXFLAGS $standard_libtool_flag"
+CXXFLAGS="$CXXFLAGS $standard_libtool_flag \$(PROF_FLAGS)"
if test "$PHP_PHAR" != "no" && test "$PHP_CLI" != "no"; then
pharcmd=pharcmd
diff --git a/ext/phar/tests/bug69453.phpt b/ext/phar/tests/bug69453.phpt
index 12b437639a..6f280a5351 100644
--- a/ext/phar/tests/bug69453.phpt
+++ b/ext/phar/tests/bug69453.phpt
@@ -14,8 +14,8 @@ $r = new Phar($fname, 0);
==DONE==
--EXPECTF--
-UnexpectedValueException: phar error: "%s/bug69453.tar.phar" is a corrupted tar file (checksum mismatch of file "") in %s:%d
+UnexpectedValueException: phar error: "%s%ebug69453.tar.phar" is a corrupted tar file (checksum mismatch of file "") in %s:%d
Stack trace:
-#0 %s/bug69453.php(%d): Phar->__construct('%s', 0)
+#0 %s%ebug69453.php(%d): Phar->__construct('%s', 0)
#1 {main}
-==DONE== \ No newline at end of file
+==DONE==
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 559f2e1aea..8066b4ebcf 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -1864,10 +1864,10 @@ consult the installation file that came with this distribution, or visit \n\
zend_first_try {
while (EXPECTED(fcgi_accept_request(&request) >= 0)) {
+ char *primary_script = NULL;
request_body_fd = -1;
SG(server_context) = (void *) &request;
init_request_info();
- char *primary_script = NULL;
fpm_request_info();
diff --git a/sapi/phpdbg/phpdbg_io.c b/sapi/phpdbg/phpdbg_io.c
index 1f004fbae1..47899abf66 100644
--- a/sapi/phpdbg/phpdbg_io.c
+++ b/sapi/phpdbg/phpdbg_io.c
@@ -178,11 +178,19 @@ PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len) {
PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo) {
+ int ret;
+
if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) {
return phpdbg_consume_bytes(sock, ptr, len, tmo);
}
- return read(sock, ptr, len);
+ ret = read(sock, ptr, len);
+ if (ret == -1 && errno == EINTR) {
+ /* Read was interrupted, retry once */
+ ret = read(sock, ptr, len);
+ }
+
+ return ret;
}
diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c
index 11bfdf5a81..4013c0fd88 100644
--- a/sapi/phpdbg/phpdbg_print.c
+++ b/sapi/phpdbg/phpdbg_print.c
@@ -282,12 +282,13 @@ void phpdbg_print_opcodes_function(const char *function, size_t len) {
}
void phpdbg_print_opcodes_method(const char *class, const char *function) {
- zend_class_entry *ce = zend_hash_str_find_ptr(EG(class_table), class, strlen(class));
+ zend_class_entry *ce;
zend_function *func;
- if (!ce) {
+ if (phpdbg_safe_class_lookup(class, strlen(class), &ce) != SUCCESS) {
return;
}
+
if (ce->type != ZEND_USER_CLASS) {
phpdbg_out("function name: %s::%s (internal)\n", class, function);
return;
@@ -348,7 +349,6 @@ void phpdbg_print_opcodes_class(const char *class) {
PHPDBG_API void phpdbg_print_opcodes(char *function)
{
char *method_name;
-
strtok(function, ":");
if (function == NULL) {
@@ -376,7 +376,7 @@ PHPDBG_API void phpdbg_print_opcodes(char *function)
} ZEND_HASH_FOREACH_END();
} else if ((method_name = strtok(NULL, ":")) == NULL) {
phpdbg_print_opcodes_function(function, strlen(function));
- } else if (++method_name == NULL || ++method_name == NULL) {
+ } else if ((method_name + 1) == NULL) {
phpdbg_print_opcodes_class(function);
} else {
phpdbg_print_opcodes_method(function, method_name);
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c
index 9d63fcf727..4cd8ce2782 100644
--- a/sapi/phpdbg/phpdbg_utils.c
+++ b/sapi/phpdbg/phpdbg_utils.c
@@ -384,7 +384,7 @@ int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry
efree(str_name);
}
- return ce ? SUCCESS : FAILURE;
+ return *ce ? SUCCESS : FAILURE;
}
char *phpdbg_get_property_key(char *key) {