Skip to content

Commit

Permalink
Merge branch 'master' of https://git.php.net/repository/php-src
Browse files Browse the repository at this point in the history
* 'master' of https://git.php.net/repository/php-src:
  use 65k of data to get a more explicit result
  double test timeout for travis
  this test is fragile on travis, let's see why
  Add test for ISSUE #128
  Fixed bug #65665 (Exception not properly caught when opcache enabled)
  Save a TSRMLS_FETCH() for zval_ptr_dtor in executor
  • Loading branch information
cjbj committed Sep 16, 2013
2 parents f71167e + ca3d5d0 commit 699b43f
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ before_script:
- . ./travis/ext/pdo_pgsql/setup.sh

# Run PHPs run-tests.php
script: ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff
script: ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120
8 changes: 4 additions & 4 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
}

#undef zval_ptr_dtor
#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC)
#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC TSRMLS_CC)

#define PZVAL_UNLOCK(z, f) zend_pzval_unlock_func(z, f, 1 TSRMLS_CC)
#define PZVAL_UNLOCK_EX(z, f, u) zend_pzval_unlock_func(z, f, u TSRMLS_CC)
Expand Down Expand Up @@ -1500,7 +1500,7 @@ void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{
}
/* }}} */

static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
{
zval ***cv = EX_CV_NUM(execute_data, 0);
zval ***end = cv + EX(op_array)->last_var;
Expand All @@ -1513,9 +1513,9 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data *exec
}
/* }}} */

void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
{
i_free_compiled_variables(execute_data);
i_free_compiled_variables(execute_data TSRMLS_CC);
}
/* }}} */

Expand Down
10 changes: 3 additions & 7 deletions Zend/zend_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,14 @@ ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char
ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ulong fetch_type, const char **class_name, zend_class_entry **pce TSRMLS_DC);
ZEND_API int zend_verify_arg_error(int error_type, const zend_function *zf, zend_uint arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind TSRMLS_DC);

static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC)
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
{
if (!Z_DELREF_P(zval_ptr)) {
TSRMLS_FETCH();

ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
zval_dtor(zval_ptr);
efree_rel(zval_ptr);
} else {
TSRMLS_FETCH();

if (Z_REFCOUNT_P(zval_ptr) == 1) {
Z_UNSET_ISREF_P(zval_ptr);
}
Expand Down Expand Up @@ -295,7 +291,7 @@ static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC
while (p != end) {
zval *q = (zval *) *(--p);
*p = NULL;
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC);
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC TSRMLS_CC);
}
if (nested) {
EG(argument_stack)->top = p;
Expand Down Expand Up @@ -394,7 +390,7 @@ ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const z
ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);

void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC);
void zend_free_compiled_variables(zend_execute_data *execute_data);
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC);

#define CACHED_PTR(num) \
EG(active_op_array)->run_time_cache[(num)]
Expand Down
3 changes: 2 additions & 1 deletion Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */

ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
{
i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC);
TSRMLS_FETCH();
i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
}
/* }}} */

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_generators.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
zend_op_array *op_array = execute_data->op_array;

if (!execute_data->symbol_table) {
zend_free_compiled_variables(execute_data);
zend_free_compiled_variables(execute_data TSRMLS_CC);
} else {
zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC);
}
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
EG(current_execute_data) = EX(prev_execute_data);
EG(opline_ptr) = NULL;
if (!EG(active_symbol_table)) {
i_free_compiled_variables(execute_data);
i_free_compiled_variables(execute_data TSRMLS_CC);
}

zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
EG(current_execute_data) = EX(prev_execute_data);
EG(opline_ptr) = NULL;
if (!EG(active_symbol_table)) {
i_free_compiled_variables(execute_data);
i_free_compiled_variables(execute_data TSRMLS_CC);
}

zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC);
Expand Down
12 changes: 8 additions & 4 deletions ext/opcache/Optimizer/block_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,11 +1283,15 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array)

/* adjust exception jump targets */
if (op_array->last_try_catch) {
int i;
for (i = 0; i< op_array->last_try_catch; i++) {
op_array->try_catch_array[i].try_op = cfg->try[i]->start_opline - new_opcodes;
op_array->try_catch_array[i].catch_op = cfg->catch[i]->start_opline - new_opcodes;
int i, j;
for (i = 0, j = 0; i< op_array->last_try_catch; i++) {
if (cfg->try[i]->access) {
op_array->try_catch_array[j].try_op = cfg->try[i]->start_opline - new_opcodes;
op_array->try_catch_array[j].catch_op = cfg->catch[i]->start_opline - new_opcodes;
j++;
}
}
op_array->last_try_catch = j;
efree(cfg->try);
efree(cfg->catch);
}
Expand Down
118 changes: 118 additions & 0 deletions ext/opcache/tests/bug65665.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
--TEST--
Bug #65665 (Exception not properly caught when opcache enabled)
--INI--
opcache.enable=1
opcache.enable_cli=1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
function foo() {
try
{
switch (1)
{
case 0:
try
{

}
catch (Exception $e)
{

}

break;

case 1:
try
{
throw new Exception('aaa');
}
catch (Exception $e)
{
echo "correct\n";
}

break;
}
}
catch (Exception $e)
{
echo "wrong\n";
}
return;
}

function foo1() {
try
{
switch (1)
{
case 0:
try
{

}
catch (Exception $e)
{
dummy:
echo "ect\n";
}

break;

case 1:
try
{
throw new Exception('aaa');
}
catch (Exception $e)
{
echo "corr";
goto dummy;
}
break;
}
}
catch (Exception $e)
{
echo "wrong\n";
}
return;
}

function foo2() {
try
{
switch (1)
{
case 0:
try
{
dummy:
throw new Exception('aaa');
}
catch (Exception $e)
{
echo "correct\n";
}

break;

case 1:
goto dummy;
break;
}
}
catch (Exception $e)
{
echo "wrong\n";
}
return;
}
foo();foo1();foo2();
--EXPECT--
correct
correct
correct
16 changes: 16 additions & 0 deletions ext/opcache/tests/issue0128.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
ISSUE #128 (opcache_invalidate segmentation fault)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
var_dump(opcache_invalidate('1'));
var_dump("okey");
?>
--EXPECT--
bool(false)
string(4) "okey"
6 changes: 4 additions & 2 deletions ext/standard/tests/file/disk_free_space_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $space1 = disk_free_space($file_path.$dir);
var_dump( $space1 );

$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a");
$data = str_repeat("x", 4096);
$data = str_repeat("x", 0xffff);
fwrite($fh, (binary)$data);
fclose($fh);

Expand All @@ -35,8 +35,10 @@ var_dump( $space2 );

if( $space1 > $space2 )
echo "\n Free Space Value Is Correct\n";
else
else {
echo "\n Free Space Value Is Incorrect\n";
var_dump($space1, $space2);
}

echo "*** Testing with Binary Input ***\n";
var_dump( disk_free_space(b"$file_path") );
Expand Down

0 comments on commit 699b43f

Please sign in to comment.