Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] Segmentation fault when try to get the 'current_execute_data' on a PHP extension

Posted by daniel gatis 
I'm trying to develop a php extension for print all functions call like a
backtrace. But when I'm trying to get the current function a segmentation
fault is throw. What is the problem with my code?

My php test code:

function a() {
b();
}

function b() {
c();
}

function c() {
var_dump(hello_world());
}

a();


My extension code:


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_hello_world.h"

PHP_FUNCTION(hello_world)
{
zend_execute_data *ptr = NULL;
ptr = EG(current_execute_data); // <----- Segmentation fault (core
dumped)
}

const zend_function_entry hello_world_functions[] = {
PHP_FE(hello_world, NULL)
PHP_FE_END
};

zend_module_entry hello_world_module_entry = {
STANDARD_MODULE_HEADER,
"hello_world",
hello_world_functions,
NULL,
NULL,
NULL,
NULL,
NULL,
PHP_hello_world_VERSION,
STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_hello_world
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(hello_world)
#endif
Sorry, only registered users may post in this forum.

Click here to login