midgardproject / midgard-php5

PHP5 API for Midgard persistent storage framework
http://www.midgard-project.org/api-docs/midgard/php/ratatoskr/
GNU Lesser General Public License v2.1
9 stars 2 forks source link

Segfault on PHPCR API test. #50

Closed piotras closed 13 years ago

piotras commented 13 years ago

Segfault when running PHPCR API test: https://github.com/phpcr/phpcr-api-tests/blob/master/tests/10_Writing/SetPropertyDynamicRebindingTest.php

Ini settings: midgard.memory_debug = On midgard.valgrind_friendly = On

Valgrind command: G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v php /usr/bin/phpunit suite/tests/10_Writing/SetPropertyDynamicRebindingTest.php

==26619== Process terminating with default action of signal 11 (SIGSEGV) ==26619== Access not within mapped region at address 0x6EF3A066 ==26619== at 0x832EF6A: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== by 0x832EF39: ??? (in /usr/bin/php5) ==26619== If you believe this happened as a result of a stack

==15564== Process terminating with default action of signal 11 (SIGSEGV) ==15564== Access not within mapped region at address 0x5C0B2CA3 ==15564== at 0x83019AC: _zval_ptr_dtor (in /usr/bin/php5) ==15564== by 0x831DEBE: _zend_hash_add_or_update (in /usr/bin/php5) ==15564== by 0x51CFF96: php_midgard_zendobject_get_properties (php_midgard_gobject_generic.c:648) ==15564== by 0x832F2E3: ??? (in /usr/bin/php5) ==15564== by 0x832F311: ??? (in /usr/bin/php5) ==15564== by 0x832F311: ??? (in /usr/bin/php5) ==15564== by 0x832F311: ??? (in /usr/bin/php5) ==15564== by 0x832F311: ??? (in /usr/bin/php5) ==15564== by 0x832F72B: gc_collect_cycles (in /usr/bin/php5) ==15564== by 0x832FBBB: gc_zobj_possible_root (in /usr/bin/php5) ==15564== by 0x832FCA3: gc_zval_possible_root (in /usr/bin/php5) ==15564== by 0x8301A18: _zval_ptr_dtor (in /usr/bin/php5)

bergie commented 13 years ago

I'm seeing this as well, another backtrace: http://friendpaste.com/7gEu3sIEwJeE0YcDGyMzKe

In my case it is the Writing\\SetPropertyMethodsTest that crashes. All SetPropertyDynamicRebindingTest passed without problems (well, with some failures)

bergie commented 13 years ago

Another backtrace on the same issue, this time with Writing\AddMethodsTest: http://friendpaste.com/8UaYMJIo7XZxHb6IsTpFs

piotras commented 13 years ago

New backtrace:

==14546== Process terminating with default action of signal 11 (SIGSEGV) ==14546== Access not within mapped region at address 0x76036012 ==14546== at 0x832F20A: ??? (in /usr/bin/php5) ==14546== by 0x832F1F9: ??? (in /usr/bin/php5) ==14546== by 0x832F1F9: ??? (in /usr/bin/php5) ==14546== by 0x832F940: gc_collect_cycles (in /usr/bin/php5) ==14546== by 0x832FE7B: gc_zobj_possible_root (in /usr/bin/php5) ==14546== by 0x832FF63: gc_zval_possible_root (in /usr/bin/php5) ==14546== by 0x8301CD8: _zval_ptr_dtor (in /usr/bin/php5) ==14546== by 0x8303E28: zend_call_function (in /usr/bin/php5) ==14546== by 0x8328841: zend_call_method (in /usr/bin/php5) ==14546== by 0x5450E64: php_midgard_gobject_new_with_gobject (php_midgard_gobject_generic.c:826) ==14546== by 0x5458899: zif__midgard_php_object_list_children (php_midgard_object.c:415) ==14546== by 0x83ABC81: execute_internal (in /usr/bin/php5)

piotras commented 13 years ago

Looks like common pattern is constructor:

zend_call_method_with_1_params(&mdate_object, php_midgard_datetime_class, &php_midgard_datetime_class->constructor, "__construct", NULL, date);

zend_call_method_with_0_params(&zvalue, ce, &ce->constructor, "__construct", NULL);

piotras commented 13 years ago

Solution is to disable gc: https://bugs.php.net/bug.php?id=51091&edit=3

bergie commented 13 years ago

Ok, that seems to help: https://github.com/bergie/phpcr-midgard2/commit/01a6bc97b6e3fda32cd3db5bbea8b1434496d2e3