Skip to content

Commit 1da4ee2

Browse files
committed
Fix oplog trace with already freed closures
1 parent 57247f0 commit 1da4ee2

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

sapi/phpdbg/phpdbg.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -615,25 +615,24 @@ static PHP_FUNCTION(phpdbg_end_oplog)
615615
zend_long insert_idx;
616616

617617
do {
618-
zend_op_array *op_array = cur->op_array;
619618
zval zero;
620619
ZVAL_LONG(&zero, 0);
621620

622-
if (op_array->filename != last_file) {
623-
last_file = op_array->filename;
621+
if (cur->filename != last_file) {
622+
last_file = cur->filename;
624623
file_ht = insert_ht = phpdbg_add_empty_array(Z_ARR_P(return_value), last_file);
625624
}
626625

627626
if (by_function) {
628-
if (op_array->function_name == NULL) {
627+
if (cur->function_name == NULL) {
629628
if (last_function != NULL) {
630629
insert_ht = file_ht;
631630
}
632631
last_function = NULL;
633-
} else if (op_array->function_name != last_function || op_array->scope != last_scope) {
632+
} else if (cur->function_name != last_function || cur->scope != last_scope) {
634633
zend_string *fn_name;
635-
last_function = op_array->function_name;
636-
last_scope = op_array->scope;
634+
last_function = cur->function_name;
635+
last_scope = cur->scope;
637636
if (last_scope == NULL) {
638637
fn_name = zend_string_copy(last_function);
639638
} else {
@@ -645,7 +644,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
645644
}
646645

647646
if (by_opcode) {
648-
insert_idx = cur->op - op_array->opcodes;
647+
insert_idx = cur->op - cur->opcodes;
649648
} else {
650649
insert_idx = cur->op->lineno;
651650
}

sapi/phpdbg/phpdbg_list.c

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
320320
*dataptr->op_array->refcount = 2;
321321
dataptr->destroy_op_array = 0;
322322
}
323+
++*dataptr->op_array->refcount;
323324
}
324325

325326
return ret;

sapi/phpdbg/phpdbg_opcode.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,17 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_fl
202202

203203
if (PHPDBG_G(oplog_list)) {
204204
phpdbg_oplog_entry *cur = zend_arena_alloc(&PHPDBG_G(oplog_arena), sizeof(phpdbg_oplog_entry));
205+
zend_op_array *op_array = &execute_data->func->op_array;
205206
cur->op = (zend_op *) execute_data->opline;
206-
cur->op_array = &execute_data->func->op_array;
207+
cur->opcodes = op_array->opcodes;
208+
cur->filename = op_array->filename;
209+
cur->scope = op_array->scope;
210+
cur->function_name = op_array->function_name;
207211
cur->next = NULL;
208212
PHPDBG_G(oplog_cur)->next = cur;
209213
PHPDBG_G(oplog_cur) = cur;
214+
if (!execute_data->func->op_array.filename)
215+
printf("ALETR");
210216
}
211217
} /* }}} */
212218

sapi/phpdbg/phpdbg_opcode.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_fl
3030
typedef struct _phpdbg_oplog_entry phpdbg_oplog_entry;
3131
struct _phpdbg_oplog_entry {
3232
phpdbg_oplog_entry *next;
33-
zend_op_array *op_array;
33+
zend_string *function_name;
34+
zend_class_entry *scope;
35+
zend_string *filename;
36+
zend_op *opcodes;
3437
zend_op *op;
3538
};
3639

0 commit comments

Comments
 (0)