pbiggar / phc

A compiler for PHP
132 stars 37 forks source link

Initialized array in class causes SIGSEGV #143

Open pbiggar opened 9 years ago

pbiggar commented 9 years ago
What steps will reproduce the problem?
1. Compile phc -c myclass.php -o myclass
2.Execute

What is the expected output? What do you see instead?

SIGSEGV error

What version of the product are you using? On what operating system?

0.2.0 on FreeBSD 7.0

Please provide any additional information below.

This code is an example. Initializing the array in the constructor eliminates the problem.
But it was very difficult to isolate the problem.

<?
/*
        my_class.php
*/
        class foobar {
                var $stuff = array (
                        'foo' => 1,
                        'bar' => 2
                );
                function foobar() {
                        // empty constructor
                }
        }
        $foobar = new foobar;

        foreach ($foobar->stuff as $key => $val)
                echo "$key => $val\n";
?>

Original issue reported on code.google.com by dennis.etinc on 2011-06-23 12:02:12

pbiggar commented 9 years ago
I would suggest trying the version from svn, rather than 0.2.0. Code gen support is
significantly improved, though I don't know for sure if it fixes this problem.

Original issue reported on code.google.com by paul.biggar on 2011-06-23 17:19:43

pbiggar commented 9 years ago
Testcase crashes for me with trunk version, too.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000403f89 in persistent_clone (in=0xa9e9fc4589, destroy_in=1)
(gdb) bt
#0  0x0000000000403f89 in persistent_clone (in=0xa9e9fc4589, destroy_in=1)
#1  0x000000000040409d in persistent_clone (in=0x754e38, destroy_in=1)
#2  0x000000000040416d in phc_declare_property (ce=0x784bd0,
    name=0x4084ce "stuff", name_length=5, property=0x754e38, access_type=256)
#3  0x0000000000407d2d in zm_startup_app (type=1, module_number=23)
#4  0x00007ffff7a1e46f in zend_startup_module_ex (module=0x7849d0)
    at /home/oliver/php-5.2.10/Zend/zend_API.c:1472
#5  0x00007ffff7a227f6 in zend_startup_module (module=<value optimized out>)
    at /home/oliver/php-5.2.10/Zend/zend_API.c:1896
#6  0x0000000000407eea in main (argc=1, argv=0x7fffffffe628)

Original issue reported on code.google.com by oliver.metz on 2011-08-19 14:34:30

pbiggar commented 9 years ago
Would love to see a patch for this, but I haven't got time to do it myself :(

Original issue reported on code.google.com by paul.biggar on 2011-08-22 08:35:12