Open marius-meissner opened 5 years ago
Same were, with the same code
PHP 7.3.4
Confirming:
OS: Ubuntu 19.04 (inside a virtualbox) PHP: 7.3.5 compiled with ZTS enabled PHP-CPP: tested master branch as well as v2.2.0 tag gcc/g++: 8.3.0 (Ubuntu 8.3.0-6ubuntu1)
Registering Interfaces and Classes works flawlessly, but as soon as a Php::Class.implements
gets called the application SIGSEGV's like shown below.
The SIGSEGV happens after the get_module
of the extension in question returns.
I included the backtrace of the crash:
Reading symbols from php...
(gdb) run
Starting program: /usr/bin/php -d extension=./libAFCORE.so tests/index.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
PHP Fatal error: Unable to instantiate in Unknown on line 0
Program received signal SIGSEGV, Segmentation fault.
0x0000555555f769c8 in zend_objects_store_put (object=0x7ffff3e0b008) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_objects_API.c:140
140 EG(objects_store).free_list_head = GET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle]);
(gdb) backtrace
#0 0x0000555555f769c8 in zend_objects_store_put (object=0x7ffff3e0b008) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_objects_API.c:140
#1 0x0000555555f6ec71 in zend_object_std_init (object=0x7ffff3e0b008, ce=0x555556cd13f0) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_objects.c:34
#2 0x00007ffff39b6d8c in Php::ObjectImpl::ObjectImpl (this=0x555556cd2d30, entry=0x555556cd13f0, base=0x0, handlers=0x555556aefef0, refcount=1) at zend/objectimpl.h:72
#3 0x00007ffff39b5b76 in Php::ClassImpl::createObject (entry=0x555556cd13f0) at zend/classimpl.cpp:1156
#4 0x0000555555f7a216 in do_implement_interface (ce=0x555556cd28e0, iface=0x555556cd13f0) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_inheritance.c:725
#5 0x0000555555f7bd73 in zend_do_implement_interface (ce=0x555556cd28e0, iface=0x555556cd13f0) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_inheritance.c:1084
#6 0x0000555555f24d8d in zend_class_implements (class_entry=0x555556cd28e0, num_interfaces=0) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_API.c:2764
#7 0x00007ffff39b64dd in Php::ClassImpl::initialize (this=0x555556af0c00, base=0x555556af1620, prefix="") at zend/classimpl.cpp:1404
#8 0x00007ffff397bdfc in Php::ExtensionImpl::<lambda(const string&, Php::ClassBase&)>::operator()(const std::__cxx11::string &, Php::ClassBase &) const (__closure=0x7fffffffde80, prefix="", c=...) at zend/extensionimpl.cpp:376
#9 0x00007ffff397c915 in std::_Function_handler<void(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, Php::ClassBase&), Php::ExtensionImpl::initialize(int)::<lambda(const string&, Php::ClassBase&)> >::_M_invoke(const std::_Any_data &, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > &, Php::ClassBase &) (__functor=..., __args#0="",
__args#1=...) at /usr/include/c++/8/bits/std_function.h:297
#10 0x00007ffff39ba96b in std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Php::ClassBase&)>::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Php::ClassBase&) const (this=0x7fffffffde80, __args#0="", __args#1=...) at /usr/include/c++/8/bits/std_function.h:687
#11 0x00007ffff39b8dc6 in Php::Namespace::classes(std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Php::ClassBase&)> const&) (this=0x7ffff3a16ce0 <get_module::extension>, callback=...) at zend/namespace.cpp:148
#12 0x00007ffff397c012 in Php::ExtensionImpl::initialize (this=0x555556aee9f0, module_number=51) at zend/extensionimpl.cpp:373
#13 0x00007ffff397b5c2 in Php::ExtensionImpl::processStartup (type=1, module_number=51) at zend/extensionimpl.cpp:119
#14 0x0000555555f21891 in zend_startup_module_ex (module=0x555556af1b40) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_API.c:1878
#15 0x0000555555f2191b in zend_startup_module_zval (zv=0x555556b04540) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_API.c:1893
#16 0x0000555555f32284 in zend_hash_apply (ht=0x555556a4d340 <module_registry>, apply_func=0x555555f218f8 <zend_startup_module_zval>) at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_hash.c:1688
#17 0x0000555555f21fbd in zend_startup_modules () at /media/dsk/build/php_latest/php-7.3.5/Zend/zend_API.c:2004
#18 0x0000555555e50fc1 in php_module_startup (sf=0x555556a2d280 <cli_sapi_module>, additional_modules=0x0, num_additional_modules=0) at /media/dsk/build/php_latest/php-7.3.5/main/main.c:2333
#19 0x0000555556006e0d in php_cli_startup (sapi_module=0x555556a2d280 <cli_sapi_module>) at /media/dsk/build/php_latest/php-7.3.5/sapi/cli/php_cli.c:420
#20 0x0000555556009440 in main (argc=4, argv=0x555556a82820) at /media/dsk/build/php_latest/php-7.3.5/sapi/cli/php_cli.c:1356
Bug or not,How to do this problem. @scorninpc
@lifenglsf, the first post show code to reproduce the problem
I have the same problem, even if trying implement interface in PHP 7.3.6.
extern "C" {
static Php::Extension extension("myextension", "0.1");
Php::Namespace AppUtilsNS("App\\Utils");
//IPrinter
Php::Interface iprinter("iPrinter");
iprinter.method("echoText", {
Php::ByVal("text", Php::Type::String, true),
Php::ByVal("toSpeach", Php::Type::Bool, false),
});
AppUtilsNS.add(iprinter);
extension.add(std::move(AppUtilsNS));
return extension;
}
In php:
use App\Utils\iPrinter;
class DummyPrinter implements iPrinter {
function echoText(string $text, bool $toSpeach = NULL) {
}
}
Fatal error: Unable to instantiate in /home/.../tests/app/utils/DummyPrinter.phpt on line 11
Any updates on this issue?
I would really appreciate if this issue would be fixed!
Any thoughts about this issue?
PHP version: 7.3.1 PHP-CPP version: 2.1.3 Compiler: g++ 8.2.0 OS: Debian 10
Custom interfaces are causing segmentation faults with PHP 7.3:
Code for reproducing:
The mentioned code works perfectly with PHP 7.1 & 7.2.
Thank you for your great effort creating and maintaining PHP-CPP!