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.

1
  • I tried with EG(return_value_ptr_ptr) global also,still i didn't get. Commented Nov 23, 2018 at 12:42

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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?
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.