1

I have created an php extension in c++ which tracks the call graph of each request(centos7-64 bit,PHP5.6).And now,I want to get the function return value of each function. It can be done by using zend_excute_data structure(original_return_value).

 zend_execute_data *data;
 data = EG(current_execute_data);
 if(data->original_return_value)
 {
        zval *rvalue = *(data->original_return_value);    // crashing here
    switch (Z_TYPE(argument_element))
        {
        ..
        .. 
        ..
    }
 }

Here, while assigning the original_return_value to rvalue,my php extension getting crash. Is this correct way to do? or anything else.

Durai
  • 87
  • 12

2 Answers2

0
zval *rvalue = *(data->original_return_value);    // crashing here

Its because of the last deref of original_return_value. Either the data object or original_return_value is uninitialized or corrupted memory.

darune
  • 10,480
  • 2
  • 24
  • 62
  • The data object has the value.May be original_return_value points the corrupted memory. Other than this,how can i get the function return value? – Durai Nov 20 '18 at 13:44
0

Finally I got it.

zval **return_value_ptr = &EX_TMP_VAR(execute_data, execute_data->opline->result.var)->var.ptr;

return_value_ptr is has the return value of currently executed function.

Durai
  • 87
  • 12