Skip to content

Commit b740bfc

Browse files
committed
Merge branch 'master' of https://git.php.net/repository/php-src
# By Michael Wallner (3) and others # Via Michael Wallner (2) and Xinchen Hui (2) * '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
2 parents c4df191 + ca3d5d0 commit b740bfc

11 files changed

+159
-22
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ before_script:
2929
- . ./travis/ext/pdo_pgsql/setup.sh
3030

3131
# Run PHPs run-tests.php
32-
script: ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff
32+
script: ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120

Zend/zend_execute.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
9494
}
9595

9696
#undef zval_ptr_dtor
97-
#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC)
97+
#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC TSRMLS_CC)
9898

9999
#define PZVAL_UNLOCK(z, f) zend_pzval_unlock_func(z, f, 1 TSRMLS_CC)
100100
#define PZVAL_UNLOCK_EX(z, f, u) zend_pzval_unlock_func(z, f, u TSRMLS_CC)
@@ -1500,7 +1500,7 @@ void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{
15001500
}
15011501
/* }}} */
15021502

1503-
static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
1503+
static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
15041504
{
15051505
zval ***cv = EX_CV_NUM(execute_data, 0);
15061506
zval ***end = cv + EX(op_array)->last_var;
@@ -1513,9 +1513,9 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data *exec
15131513
}
15141514
/* }}} */
15151515

1516-
void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
1516+
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
15171517
{
1518-
i_free_compiled_variables(execute_data);
1518+
i_free_compiled_variables(execute_data TSRMLS_CC);
15191519
}
15201520
/* }}} */
15211521

Zend/zend_execute.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,14 @@ ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char
7171
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);
7272
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);
7373

74-
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC)
74+
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
7575
{
7676
if (!Z_DELREF_P(zval_ptr)) {
77-
TSRMLS_FETCH();
78-
7977
ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
8078
GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
8179
zval_dtor(zval_ptr);
8280
efree_rel(zval_ptr);
8381
} else {
84-
TSRMLS_FETCH();
85-
8682
if (Z_REFCOUNT_P(zval_ptr) == 1) {
8783
Z_UNSET_ISREF_P(zval_ptr);
8884
}
@@ -295,7 +291,7 @@ static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC
295291
while (p != end) {
296292
zval *q = (zval *) *(--p);
297293
*p = NULL;
298-
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC);
294+
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC TSRMLS_CC);
299295
}
300296
if (nested) {
301297
EG(argument_stack)->top = p;
@@ -394,7 +390,7 @@ ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const z
394390
ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
395391

396392
void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC);
397-
void zend_free_compiled_variables(zend_execute_data *execute_data);
393+
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC);
398394

399395
#define CACHED_PTR(num) \
400396
EG(active_op_array)->run_time_cache[(num)]

Zend/zend_execute_API.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */
423423

424424
ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
425425
{
426-
i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC);
426+
TSRMLS_FETCH();
427+
i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
427428
}
428429
/* }}} */
429430

Zend/zend_generators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
4646
zend_op_array *op_array = execute_data->op_array;
4747

4848
if (!execute_data->symbol_table) {
49-
zend_free_compiled_variables(execute_data);
49+
zend_free_compiled_variables(execute_data TSRMLS_CC);
5050
} else {
5151
zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC);
5252
}

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
18331833
EG(current_execute_data) = EX(prev_execute_data);
18341834
EG(opline_ptr) = NULL;
18351835
if (!EG(active_symbol_table)) {
1836-
i_free_compiled_variables(execute_data);
1836+
i_free_compiled_variables(execute_data TSRMLS_CC);
18371837
}
18381838

18391839
zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC);

Zend/zend_vm_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
396396
EG(current_execute_data) = EX(prev_execute_data);
397397
EG(opline_ptr) = NULL;
398398
if (!EG(active_symbol_table)) {
399-
i_free_compiled_variables(execute_data);
399+
i_free_compiled_variables(execute_data TSRMLS_CC);
400400
}
401401

402402
zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC);

ext/opcache/Optimizer/block_pass.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,11 +1283,15 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array)
12831283

12841284
/* adjust exception jump targets */
12851285
if (op_array->last_try_catch) {
1286-
int i;
1287-
for (i = 0; i< op_array->last_try_catch; i++) {
1288-
op_array->try_catch_array[i].try_op = cfg->try[i]->start_opline - new_opcodes;
1289-
op_array->try_catch_array[i].catch_op = cfg->catch[i]->start_opline - new_opcodes;
1286+
int i, j;
1287+
for (i = 0, j = 0; i< op_array->last_try_catch; i++) {
1288+
if (cfg->try[i]->access) {
1289+
op_array->try_catch_array[j].try_op = cfg->try[i]->start_opline - new_opcodes;
1290+
op_array->try_catch_array[j].catch_op = cfg->catch[i]->start_opline - new_opcodes;
1291+
j++;
1292+
}
12901293
}
1294+
op_array->last_try_catch = j;
12911295
efree(cfg->try);
12921296
efree(cfg->catch);
12931297
}

ext/opcache/tests/bug65665.phpt

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
--TEST--
2+
Bug #65665 (Exception not properly caught when opcache enabled)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--SKIPIF--
7+
<?php require_once('skipif.inc'); ?>
8+
--FILE--
9+
<?php
10+
function foo() {
11+
try
12+
{
13+
switch (1)
14+
{
15+
case 0:
16+
try
17+
{
18+
19+
}
20+
catch (Exception $e)
21+
{
22+
23+
}
24+
25+
break;
26+
27+
case 1:
28+
try
29+
{
30+
throw new Exception('aaa');
31+
}
32+
catch (Exception $e)
33+
{
34+
echo "correct\n";
35+
}
36+
37+
break;
38+
}
39+
}
40+
catch (Exception $e)
41+
{
42+
echo "wrong\n";
43+
}
44+
return;
45+
}
46+
47+
function foo1() {
48+
try
49+
{
50+
switch (1)
51+
{
52+
case 0:
53+
try
54+
{
55+
56+
}
57+
catch (Exception $e)
58+
{
59+
dummy:
60+
echo "ect\n";
61+
}
62+
63+
break;
64+
65+
case 1:
66+
try
67+
{
68+
throw new Exception('aaa');
69+
}
70+
catch (Exception $e)
71+
{
72+
echo "corr";
73+
goto dummy;
74+
}
75+
break;
76+
}
77+
}
78+
catch (Exception $e)
79+
{
80+
echo "wrong\n";
81+
}
82+
return;
83+
}
84+
85+
function foo2() {
86+
try
87+
{
88+
switch (1)
89+
{
90+
case 0:
91+
try
92+
{
93+
dummy:
94+
throw new Exception('aaa');
95+
}
96+
catch (Exception $e)
97+
{
98+
echo "correct\n";
99+
}
100+
101+
break;
102+
103+
case 1:
104+
goto dummy;
105+
break;
106+
}
107+
}
108+
catch (Exception $e)
109+
{
110+
echo "wrong\n";
111+
}
112+
return;
113+
}
114+
foo();foo1();foo2();
115+
--EXPECT--
116+
correct
117+
correct
118+
correct

ext/opcache/tests/issue0128.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
ISSUE #128 (opcache_invalidate segmentation fault)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
var_dump(opcache_invalidate('1'));
12+
var_dump("okey");
13+
?>
14+
--EXPECT--
15+
bool(false)
16+
string(4) "okey"

ext/standard/tests/file/disk_free_space_basic.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $space1 = disk_free_space($file_path.$dir);
2525
var_dump( $space1 );
2626

2727
$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a");
28-
$data = str_repeat("x", 4096);
28+
$data = str_repeat("x", 0xffff);
2929
fwrite($fh, (binary)$data);
3030
fclose($fh);
3131

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

3636
if( $space1 > $space2 )
3737
echo "\n Free Space Value Is Correct\n";
38-
else
38+
else {
3939
echo "\n Free Space Value Is Incorrect\n";
40+
var_dump($space1, $space2);
41+
}
4042

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

0 commit comments

Comments
 (0)