Segmentation fault when try to get the 'current_execute_data' on a PHP extension
| From: | daniel gatis | Date: | Thu, 20 Apr 2017 22:27:49 +0000 |
| Subject: | Segmentation fault when try to get the 'current_execute_data' on a PHP extension | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-98832@lists.php.net to get a copy of this message | ||
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