Skip to content

Commit 11b041d

Browse files
committed
Fixed bug #78973
Save opline in leave helper to correctly handle destructor calls during CV freeing (or other leave freeing).
1 parent 6ef7e53 commit 11b041d

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
- Core:
77
. Fixed bug #78929 (plus signs in cookie values are converted to spaces).
88
(Alexey Kachalin)
9+
. Fixed bug #78973 (Destructor during CV freeing causes segfault if opline
10+
never saved). (Nikita)
911

1012
- OPcache:
1113
. Fixed bug #78961 (erroneous optimization of re-assigned $GLOBALS). (Dmitry)

Zend/tests/bug78973.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #78973: Destructor during CV freeing causes segfault if opline never saved
3+
--FILE--
4+
<?php
5+
6+
function test($x) {
7+
}
8+
test(new class {
9+
public function __destruct() {
10+
debug_print_backtrace();
11+
}
12+
});
13+
14+
?>
15+
--EXPECTF--
16+
#0 class@anonymous->__destruct() called at [%s:4]
17+
#1 test() called at [%s:5]

Zend/zend_vm_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,7 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
28672867
{
28682868
zend_execute_data *old_execute_data;
28692869
uint32_t call_info = EX_CALL_INFO();
2870+
SAVE_OPLINE();
28702871

28712872
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) {
28722873
i_free_compiled_variables(execute_data);

Zend/zend_vm_execute.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper
11301130
{
11311131
zend_execute_data *old_execute_data;
11321132
uint32_t call_info = EX_CALL_INFO();
1133+
SAVE_OPLINE();
11331134

11341135
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) {
11351136
i_free_compiled_variables(execute_data);
@@ -53445,6 +53446,7 @@ ZEND_API void execute_ex(zend_execute_data *ex)
5344553446
{
5344653447
zend_execute_data *old_execute_data;
5344753448
uint32_t call_info = EX_CALL_INFO();
53449+
SAVE_OPLINE();
5344853450

5344953451
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) {
5345053452
i_free_compiled_variables(execute_data);

0 commit comments

Comments
 (0)