phpv8 / v8js

V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
http://pecl.php.net/package/v8js
MIT License
1.83k stars 200 forks source link

Crash with property declaration in class derived from V8Js class #54

Closed stesie closed 10 years ago

stesie commented 10 years ago

The following code runs as expected in PHP 5.3.3 but crashes PHP 5.4.4

<?php

class V8Wrapper extends V8Js {
    public $testing;  // remove line to make it work :-)

    public function __construct() {
        parent::__construct();
        $this->testing = 23;
    }
}

$v8 = new V8Wrapper();
$v8->executeString("print('foo');");

Backtrace of crashed PHP 5.4.4 instance:

Program received signal SIGSEGV, Segmentation fault.
0x00000000006c3da1 in zend_std_write_property (object=0x7ffff7e67838, member=0x7ffff7e68a28, value=0x1ae791fcf187e3, key=0x7ffff7e68a28)
    at /tmp/buildd/php5-5.4.4/Zend/zend_object_handlers.c:527
527 /tmp/buildd/php5-5.4.4/Zend/zend_object_handlers.c: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0  0x00000000006c3da1 in zend_std_write_property (object=0x7ffff7e67838, member=0x7ffff7e68a28, value=0x1ae791fcf187e3, key=0x7ffff7e68a28)
    at /tmp/buildd/php5-5.4.4/Zend/zend_object_handlers.c:527
#1  0x00007fffeedfdafd in php_v8js_write_property (object=0x7ffff7e65090, member=0x7ffff7e68a28, value=0x7ffff7e67838, key=0x7ffff7e68a28) at /home/sts/Projekte/v8js/v8js.cc:1182
#2  0x000000000071e3ef in zend_assign_to_object (retval=0x0, object_ptr=0xdb9720, property_name=0xdb94c0, value_type=1, value_op=0x0, Ts=0x0, opcode=7466804, key=0x7ffff7e68a28)
    at /tmp/buildd/php5-5.4.4/Zend/zend_execute.c:737
#3  0x000000000071ef34 in ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_HANDLER (execute_data=0x7ffff7e32200) at /tmp/buildd/php5-5.4.4/Zend/zend_vm_execute.h:22253
#4  0x0000000000700927 in execute (op_array=0x7ffff7e67db0) at /tmp/buildd/php5-5.4.4/Zend/zend_vm_execute.h:410
#5  0x00000000006a076e in zend_execute_scripts (type=8, retval=0x7ffff7e65968, file_count=3) at /tmp/buildd/php5-5.4.4/Zend/zend.c:1279
#6  0x000000000063fc93 in php_execute_script (primary_file=0x7fffffff9f90) at /tmp/buildd/php5-5.4.4/main/main.c:2473
#7  0x0000000000749693 in do_cli (argc=0, argv=0x7fffffffe7d5) at /tmp/buildd/php5-5.4.4/sapi/cli/php_cli.c:988
#8  0x00000000004312aa in main (argc=32767, argv=0xdba210) at /tmp/buildd/php5-5.4.4/sapi/cli/php_cli.c:1361

If the public $testing; property declaration is removed from the code everything works well, even with PHP 5.4.4

I probably will have a go to fix this, but do we want to fix this, or do you consider it expected behaviour? (after all it shouldn't crash no matter what)

cheers stesie

satoshi75nakamoto commented 10 years ago

I'd try to fix it.