2
votes

Today when i tried to run phpunit with a few tests in the Yii framework i received a segmentation fault. this also with a new test. strangely, this does not happy with any other Yii installations nor with the functional tests that use selenium

running the test:

root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# phpunit unit
Segmentation fault
root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests#

gdb:

root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# gdb --args php /usr/bin/phpunit unit
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/php...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/bin/php /usr/bin/phpunit unit
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffec9fd700 (LWP 5572)]
[Thread 0x7fffec9fd700 (LWP 5572) exited]

Program received signal SIGSEGV, Segmentation fault.
0x0000000000685768 in zend_get_class_entry ()
(gdb)

ddb backtrace:

(gdb)bt
#0  0x0000000000685768 in zend_get_class_entry ()
#1  0x000000000069a94f in zend_call_method ()
#2  0x00000000005837e6 in ?? ()
#3  0x000000000067982d in zend_call_function ()
#4  0x0000000000679e4c in zend_lookup_class_ex ()
#5  0x000000000067a120 in zend_fetch_class ()
#6  0x00000000006aa871 in ?? ()
#7  0x00000000006abe00 in execute ()
#8  0x00007ffff4602379 in xdebug_execute (op_array=0x160d178) at /tmp/pear/temp/xdebug/xdebug.c:1435
#9  0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#10 0x00000000006c02cc in ?? ()
#11 0x00000000006abe00 in execute ()
#12 0x00007ffff4602379 in xdebug_execute (op_array=0x113a7a0) at /tmp/pear/temp/xdebug/xdebug.c:1435
#13 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#14 0x0000000000679784 in zend_call_function ()
#15 0x000000000069a8d7 in zend_call_method ()
#16 0x00000000005837e6 in ?? ()
#17 0x000000000067982d in zend_call_function ()
#18 0x0000000000679e4c in zend_lookup_class_ex ()
#19 0x000000000067a120 in zend_fetch_class ()
#20 0x00000000006aa871 in ?? ()
#21 0x00000000006abe00 in execute ()
#22 0x00007ffff4602379 in xdebug_execute (op_array=0x102c4c0) at /tmp/pear/temp/xdebug/xdebug.c:1435
#23 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#24 0x00000000006b279d in ?? ()
#25 0x00000000006abe00 in execute ()
#26 0x00007ffff4602379 in xdebug_execute (op_array=0x1107e70) at /tmp/pear/temp/xdebug/xdebug.c:1435
#27 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#28 0x00000000006d4876 in ?? ()
#29 0x00000000006abe00 in execute ()
#30 0x00007ffff4602379 in xdebug_execute (op_array=0x11087d0) at /tmp/pear/temp/xdebug/xdebug.c:1435
#31 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#32 0x00000000006d4876 in ?? ()
#33 0x00000000006abe00 in execute ()
#34 0x00007ffff4602379 in xdebug_execute (op_array=0x7fffebe930f8) at /tmp/pear/temp/xdebug/xdebug.c:1435
#35 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#36 0x00000000006d4876 in ?? ()
#37 0x00000000006abe00 in execute ()
#38 0x00007ffff4602379 in xdebug_execute (op_array=0x7fffebea01d8) at /tmp/pear/temp/xdebug/xdebug.c:1435
#39 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#40 0x00000000006d4876 in ?? ()
#41 0x00000000006abe00 in execute ()
#42 0x00007ffff4602379 in xdebug_execute (op_array=0x157be08) at /tmp/pear/temp/xdebug/xdebug.c:1435
#43 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#44 0x00000000006d4876 in ?? ()
#45 0x00000000006abe00 in execute ()
#46 0x00007ffff4602379 in xdebug_execute (op_array=0x10353d8) at /tmp/pear/temp/xdebug/xdebug.c:1435
#47 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
---Type <return> to continue, or q <return> to quit---
#48 0x00000000006d4876 in ?? ()
#49 0x00000000006abe00 in execute ()
#50 0x00007ffff4602379 in xdebug_execute (op_array=0x1040f20) at /tmp/pear/temp/xdebug/xdebug.c:1435
#51 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#52 0x00000000006d4876 in ?? ()
#53 0x00000000006abe00 in execute ()
#54 0x00007ffff4602379 in xdebug_execute (op_array=0x102aa90) at /tmp/pear/temp/xdebug/xdebug.c:1435
#55 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#56 0x00000000006835cd in zend_execute_scripts ()
#57 0x000000000062eb98 in php_execute_script ()
#58 0x000000000071413a in ?? ()
#59 0x00007ffff5471c8d in __libc_start_main () from /lib/libc.so.6
#60 0x000000000042d6e9 in _start ()

php version:

root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# php -v
PHP 5.3.3-7+squeeze19 with Suhosin-Patch (cli) (built: Feb 17 2014 10:10:23)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

phpunit version:

root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# phpunit --version
PHPUnit 3.7.24 by Sebastian Bergmann.

phpunit.ini (which was stripped down to disable selenium, clover-coverage, coverage-html and junit):

<phpunit
      bootstrap="bootstrap.php"
        colors="false"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
      strict="false"
      verbose="true"
        stopOnFailure="false">
  <selenium>
    <browser name="Internet Explorer" browser="*iexplore" />
    <browser name="Firefox" browser="*firefox" />
  </selenium>

</phpunit>

bootstrap.php:

<?php

// change the following paths if necessary
$yiit=dirname(__FILE__).'/../../../../framework/yiit.php';
$config=dirname(__FILE__).'/../config/test.php';
require_once($yiit);
require_once(dirname(__FILE__).'/WebTestCase.php');
Yii::createWebApplication($config);

test in the folder unit:

<?php
class JasperTest extends CDbTestCase
{
    public function testPushAndPop()
    {
        //$stack = array();
        $this->assertEquals(true, true);
/*
        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
 */
    }
}

addition: disabled xdebug which produced the backtrace:

#0  0x0000000000685768 in zend_get_class_entry ()
#1  0x000000000069a94f in zend_call_method ()
#2  0x00000000005837e6 in ?? ()
#3  0x000000000067982d in zend_call_function ()
#4  0x0000000000679e4c in zend_lookup_class_ex ()
#5  0x000000000067a120 in zend_fetch_class ()
#6  0x00000000006aa871 in ?? ()
#7  0x00000000006abe00 in execute ()
#8  0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#9  0x00000000006c02cc in ?? ()
#10 0x00000000006abe00 in execute ()
#11 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#12 0x0000000000679784 in zend_call_function ()
#13 0x000000000069a8d7 in zend_call_method ()
#14 0x00000000005837e6 in ?? ()
#15 0x000000000067982d in zend_call_function ()
#16 0x0000000000679e4c in zend_lookup_class_ex ()
#17 0x000000000067a120 in zend_fetch_class ()
#18 0x00000000006aa871 in ?? ()
#19 0x00000000006abe00 in execute ()
#20 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#21 0x00000000006b279d in ?? ()
#22 0x00000000006abe00 in execute ()
#23 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#24 0x00000000006d4876 in ?? ()
#25 0x00000000006abe00 in execute ()
#26 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#27 0x00000000006d4876 in ?? ()
#28 0x00000000006abe00 in execute ()
#29 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#30 0x00000000006d4876 in ?? ()
#31 0x00000000006abe00 in execute ()
#32 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#33 0x00000000006d4876 in ?? ()
#34 0x00000000006abe00 in execute ()
#35 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#36 0x00000000006d4876 in ?? ()
#37 0x00000000006abe00 in execute ()
#38 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#39 0x00000000006d4876 in ?? ()
#40 0x00000000006abe00 in execute ()
#41 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#42 0x00000000006d4876 in ?? ()
#43 0x00000000006abe00 in execute ()
#44 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#45 0x00000000006835cd in zend_execute_scripts ()
#46 0x000000000062eb98 in php_execute_script ()
#47 0x000000000071413a in ?? ()
---Type <return> to continue, or q <return> to quit---
#48 0x00007ffff5471c8d in __libc_start_main () from /lib/libc.so.6
#49 0x000000000042d6e9 in _start ()

anyone know how i can fix this?

1
This looks more like a bugreport, than a question. - Zaffy

1 Answers

1
votes

I'm going to guess that you are using Yii 1.1.12 or lower, given that this issue was patched in 1.1.13.

Open up yii/framework/test/CTestCase.php and make the following changes:

Replace

require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
spl_autoload_unregister('phpunit_autoload');
Yii::registerAutoloader('phpunit_autoload');

with the new code form 1.1.13

require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11

spl_autoload_unregister(array('YiiBase','autoload'));
require_once('PHPUnit/Autoload.php');
spl_autoload_register(array('YiiBase','autoload')); // put yii's autoloader at the end

if (in_array('phpunit_autoload', spl_autoload_functions())) { // PHPUnit >= 3.7 'phpunit_autoload' was obsoleted
    spl_autoload_unregister('phpunit_autoload');
    Yii::registerAutoloader('phpunit_autoload');
}

I ran into this issue myself, and if I recall correctly, this solved the problem.