Skip to content

Commit 7c520fa

Browse files
committed
Merge remote-tracking branch 'php/master' into win_mb_path_w_only
* php/master: fix NEWS add missing NEWS entry bump news file Revert "bump news file" bump news file Added test Fixed bug #72202 (curl_close doesn't close cURL handle) Now curl_close() forces connection close, independently of other links to the same resource. update NEWS #72337 invalid dimensions can lead to segv 7.0.9 next cleanup Fixed mixed declarations and code Add test for bug #53735 micro-optimization simplification Improve type narrowing (check only SSA definitions). Fix correctness issues with type narrowing
2 parents eb753f7 + f4a0011 commit 7c520fa

File tree

13 files changed

+467
-231
lines changed

13 files changed

+467
-231
lines changed

NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? 2016, PHP 7.1.0
3+
?? ??? 2016, PHP 7.1.0alpha2
4+
5+
6+
7+
09 Jun 2016, PHP 7.1.0alpha1
48

59
- Core:
610
. Added nullable types. (Levi, Dmitry)

Zend/tests/bug72335.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Misoptimize due to type narrowing
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
$b = false;
8+
$x = (1<<53)+1;
9+
do {
10+
$x = 1.0 * ($x - (1<<53));
11+
} while ($b);
12+
return $x;
13+
}
14+
var_dump(test());
15+
16+
?>
17+
--EXPECT--
18+
float(1)

Zend/zend_bitset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static inline int zend_bitset_last(zend_bitset set, uint32_t len)
221221
#define ZEND_BITSET_FOREACH(set, len, bit) do { \
222222
zend_bitset _set = (set); \
223223
uint32_t _i, _len = (len); \
224-
for (_i = 0; _i < len; _i++) { \
224+
for (_i = 0; _i < _len; _i++) { \
225225
zend_ulong _x = _set[_i]; \
226226
if (_x) { \
227227
(bit) = ZEND_BITSET_ELM_SIZE * 8 * _i; \

Zend/zend_execute.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,10 @@ static zend_always_inline void zend_vm_stack_free_call_frame_ex(uint32_t call_in
259259
ZEND_ASSERT_VM_STACK_GLOBAL;
260260

261261
if (UNEXPECTED(call_info & ZEND_CALL_ALLOCATED)) {
262-
ZEND_ASSERT(call == (zend_execute_data*)ZEND_VM_STACK_ELEMENTS(EG(vm_stack)));
263-
264262
zend_vm_stack p = EG(vm_stack);
265263
zend_vm_stack prev = p->prev;
266264

265+
ZEND_ASSERT(call == (zend_execute_data*)ZEND_VM_STACK_ELEMENTS(EG(vm_stack)));
267266
EG(vm_stack_top) = prev->top;
268267
EG(vm_stack_end) = prev->end;
269268
EG(vm_stack) = prev;

Zend/zend_vm_def.h

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ ZEND_VM_C_LABEL(assign_dim_op_convert_to_array):
848848
if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
849849
ZEND_VM_C_GOTO(assign_dim_op_convert_to_array);
850850
}
851-
if (UNEXPECTED(!Z_ISERROR_P(container))) {
851+
if (UNEXPECTED(OP1_TYPE != IS_VAR || !Z_ISERROR_P(container))) {
852852
zend_error(E_WARNING, "Cannot use a scalar value as an array");
853853
}
854854
ZEND_VM_C_LABEL(assign_dim_op_ret_null):
@@ -2503,56 +2503,69 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
25032503
zend_execute_data *old_execute_data;
25042504
uint32_t call_info = EX_CALL_INFO();
25052505

2506-
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) {
2506+
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) {
25072507
i_free_compiled_variables(execute_data);
2508-
if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED))) {
2509-
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
2510-
zend_clean_and_cache_symbol_table(EX(symbol_table));
2511-
}
2512-
EG(current_execute_data) = EX(prev_execute_data);
2513-
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
2514-
zend_object *object = Z_OBJ(execute_data->This);
2508+
2509+
EG(current_execute_data) = EX(prev_execute_data);
2510+
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
2511+
zend_object *object = Z_OBJ(execute_data->This);
25152512
#if 0
2516-
if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
2513+
if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
25172514
#else
2518-
if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) {
2515+
if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) {
25192516
#endif
2520-
GC_REFCOUNT(object)--;
2521-
if (GC_REFCOUNT(object) == 1) {
2522-
zend_object_store_ctor_failed(object);
2523-
}
2517+
GC_REFCOUNT(object)--;
2518+
if (GC_REFCOUNT(object) == 1) {
2519+
zend_object_store_ctor_failed(object);
25242520
}
2525-
OBJ_RELEASE(object);
2526-
} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2527-
OBJ_RELEASE((zend_object*)execute_data->func->op_array.prototype);
25282521
}
2522+
OBJ_RELEASE(object);
2523+
} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2524+
OBJ_RELEASE((zend_object*)execute_data->func->op_array.prototype);
2525+
}
2526+
EG(vm_stack_top) = (zval*)execute_data;
2527+
execute_data = EX(prev_execute_data);
25292528

2530-
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
2531-
old_execute_data = execute_data;
2532-
execute_data = EX(prev_execute_data);
2533-
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
2534-
} else {
2535-
EG(current_execute_data) = EX(prev_execute_data);
2536-
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
2537-
zend_object *object = Z_OBJ(execute_data->This);
2529+
if (UNEXPECTED(EG(exception) != NULL)) {
2530+
const zend_op *old_opline = EX(opline);
2531+
zend_throw_exception_internal(NULL);
2532+
if (RETURN_VALUE_USED(old_opline)) {
2533+
zval_ptr_dtor(EX_VAR(old_opline->result.var));
2534+
}
2535+
HANDLE_EXCEPTION_LEAVE();
2536+
}
2537+
2538+
LOAD_NEXT_OPLINE();
2539+
ZEND_VM_LEAVE();
2540+
} else if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) {
2541+
i_free_compiled_variables(execute_data);
2542+
2543+
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
2544+
zend_clean_and_cache_symbol_table(EX(symbol_table));
2545+
}
2546+
EG(current_execute_data) = EX(prev_execute_data);
2547+
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
2548+
zend_object *object = Z_OBJ(execute_data->This);
25382549
#if 0
2539-
if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
2550+
if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
25402551
#else
2541-
if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) {
2552+
if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) {
25422553
#endif
2543-
GC_REFCOUNT(object)--;
2544-
if (GC_REFCOUNT(object) == 1) {
2545-
zend_object_store_ctor_failed(object);
2546-
}
2554+
GC_REFCOUNT(object)--;
2555+
if (GC_REFCOUNT(object) == 1) {
2556+
zend_object_store_ctor_failed(object);
25472557
}
2548-
OBJ_RELEASE(object);
2549-
} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2550-
OBJ_RELEASE((zend_object*)execute_data->func->op_array.prototype);
25512558
}
2552-
EG(vm_stack_top) = (zval*)execute_data;
2553-
execute_data = EX(prev_execute_data);
2559+
OBJ_RELEASE(object);
2560+
} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2561+
OBJ_RELEASE((zend_object*)execute_data->func->op_array.prototype);
25542562
}
25552563

2564+
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
2565+
old_execute_data = execute_data;
2566+
execute_data = EX(prev_execute_data);
2567+
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
2568+
25562569
if (UNEXPECTED(EG(exception) != NULL)) {
25572570
const zend_op *old_opline = EX(opline);
25582571
zend_throw_exception_internal(NULL);
@@ -4300,20 +4313,15 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR, NUM)
43004313
zval *varptr, *arg;
43014314

43024315
varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
4316+
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4317+
ZVAL_COPY_VALUE(arg, varptr);
43034318

43044319
if (EXPECTED(Z_ISREF_P(varptr))) {
4305-
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4306-
ZVAL_COPY_VALUE(arg, varptr);
4307-
43084320
ZEND_VM_NEXT_OPCODE();
43094321
}
43104322

43114323
SAVE_OPLINE();
43124324
zend_error(E_NOTICE, "Only variables should be passed by reference");
4313-
4314-
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4315-
ZVAL_COPY_VALUE(arg, varptr);
4316-
43174325
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
43184326
}
43194327

@@ -4330,12 +4338,11 @@ ZEND_VM_HANDLER(50, ZEND_SEND_VAR_NO_REF_EX, VAR, NUM, SPEC(QUICK_ARG))
43304338
}
43314339

43324340
varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
4341+
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4342+
ZVAL_COPY_VALUE(arg, varptr);
43334343

43344344
if (EXPECTED(Z_ISREF_P(varptr) ||
43354345
QUICK_ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num))) {
4336-
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4337-
ZVAL_COPY_VALUE(arg, varptr);
4338-
43394346
ZEND_VM_NEXT_OPCODE();
43404347
}
43414348
} else {
@@ -4344,22 +4351,17 @@ ZEND_VM_HANDLER(50, ZEND_SEND_VAR_NO_REF_EX, VAR, NUM, SPEC(QUICK_ARG))
43444351
}
43454352

43464353
varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
4354+
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4355+
ZVAL_COPY_VALUE(arg, varptr);
43474356

43484357
if (EXPECTED(Z_ISREF_P(varptr) ||
43494358
ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num))) {
4350-
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4351-
ZVAL_COPY_VALUE(arg, varptr);
4352-
43534359
ZEND_VM_NEXT_OPCODE();
43544360
}
43554361
}
43564362

43574363
SAVE_OPLINE();
43584364
zend_error(E_NOTICE, "Only variables should be passed by reference");
4359-
4360-
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4361-
ZVAL_COPY_VALUE(arg, varptr);
4362-
43634365
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
43644366
}
43654367

@@ -4374,7 +4376,8 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, NUM)
43744376

43754377
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
43764378
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(varptr))) {
4377-
ZVAL_NEW_REF(arg, &EG(uninitialized_zval));
4379+
ZVAL_NEW_EMPTY_REF(arg);
4380+
ZVAL_NULL(Z_REFVAL_P(arg));
43784381
ZEND_VM_NEXT_OPCODE();
43794382
}
43804383

0 commit comments

Comments
 (0)