Bug #70033 [Opn]: segfault while running tests in phpunit

From: Date: Thu, 09 Jul 2015 09:51:02 +0000
Subject: Bug #70033 [Opn]: segfault while running tests in phpunit
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194248@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70033&edit=1

 ID:                 70033
 Updated by:         laruence@php.net
 Reported by:        kolesnikov dot p at hotmail dot com
 Summary:            segfault while running tests in phpunit
 Status:             Open
 Type:               Bug
 Package:            Reproducible crash
 Operating System:   Ubuntu 14.04
 PHP Version:        7.0Git-2015-07-09 (Git)
-Assigned To:        
+Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

a more simple reproduce scripts is:
<?php
class saboteurTestController {
    public function isConsistent() { throw new \Exception(); }
}

function testException() {
    $controllers = array(new saboteurTestController());
    foreach ($controllers as $controller) {
        try {
            if ($controller->isConsistent()) {
                return $controller;
            }
        } catch (\Exception $e) {}
    }
}

testException();


Previous Comments:
------------------------------------------------------------------------
[2015-07-09 07:56:04] kolesnikov dot p at hotmail dot com

Description:
------------
Test script below runs fine on PHP 5.5.9 and produces segfault on PHP 7 compiled from latest git
with following config:

'./configure'  '--prefix=/home/dev/php7/usr' '--with-apxs2'
'--with-xsl=/usr/lib/x86_64-linux-gnu/' '--with-curl'
'--enable-memcached' '--disable-memcached-sasl' '--with-tidy'
'--with-mcrypt' '--with-gd' '--enable-intl' '--enable-zip'
'--enable-soap' '--with-mysql-sock=/var/lib/mysql/mysql.sock'
'--enable-sockets' '--with-mysqli' '--with-openssl'
'--enable-opcache' '--with-zlib'

PHPUnit version 4.7.6

To reproduce segfault its necessary to run both tests from test class:
  phpunit saboteurTest.php

If any of tests is skipped like:
  phpunit --filter testException saboteurTest.php
phpunit will finish test execution successfully.


Test script:
---------------
class saboteurTest extends TestCase {

    function testException() {
        $controllers = array(new saboteurTestController());
        foreach ($controllers as $controller) {
            try {
                if ($controller->isConsistent()) return $controller;
            } catch (\Exception $e) {}
        }
    }

    function testAny() {
        $this->assertTrue(true);
    }
}

class saboteurTestController {
    public function isConsistent() { throw new \Exception(); }
}

Expected result:
----------------
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.
..
Time: 220 ms, Memory: 8.00Mb
OK (2 tests, 1 assertion)

Actual result:
--------------
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.
.Segmentation fault (core dumped)

(gdb) bt
#0  zend_mm_alloc_small (size=56, bin_num=6, heap=0x7f7f40e00040) at
/home/dev/php-src/Zend/zend_alloc.c:1244
#1  _emalloc_56 () at /home/dev/php-src/Zend/zend_alloc.c:2132
#2  0x00000000007f5c70 in _array_init (arg=arg@entry=0x7f7f405c77c0, size=1) at
/home/dev/php-src/Zend/zend_API.c:1087
#3  0x000000000073ec72 in php_var_unserialize_ex (rval=rval@entry=0x7f7f405c77c0,
p=p@entry=0x7ffff2c57588,
    max=max@entry=0x7f7f405ba4de "", var_hash=var_hash@entry=0x7ffff2c57590,
classes=classes@entry=0x0) at 
    ext/standard/var_unserializer.re:704
#4  0x000000000073ed33 in process_nested_data (rval=0x7f7f40529380, objprops=0, elements=0,
ht=0x7f7f40529380, 
    classes=0x0, var_hash=0x7ffff2c57590, max=0x7f7f405ba4de "", p=0x7ffff2c57588) at
ext/standard/var_unserializer.re:395
#5  php_var_unserialize_ex (rval=rval@entry=0x7f7f40590338, p=p@entry=0x7ffff2c57588,
max=max@entry=0x7f7f405ba4de "",
    var_hash=var_hash@entry=0x7ffff2c57590, classes=classes@entry=0x0) at
ext/standard/var_unserializer.re:709
#6  0x00000000004434b0 in process_nested_data (rval=0x7f7f405d0780, objprops=1, elements=0,
ht=0x7f7f4058cb28, classes=0x0,
    var_hash=0x7ffff2c57590, max=0x7f7f405ba4de "", p=0x7ffff2c57588) at
ext/standard/var_unserializer.re:395
#7  object_common2 (rval=0x7f7f405d0780, p=0x7ffff2c57588, max=0x7f7f405ba4de "",
var_hash=0x7ffff2c57590, classes=0x0,
    elements=<optimized out>) at ext/standard/var_unserializer.re:479
#8  0x000000000073f0a2 in php_var_unserialize_ex (rval=rval@entry=0x7f7f405d0780,
p=p@entry=0x7ffff2c57588, 
    max=max@entry=0x7f7f405ba4de "", var_hash=var_hash@entry=0x7ffff2c57590,
classes=classes@entry=0x0) at 
    ext/standard/var_unserializer.re:720
#9  0x000000000073ed33 in process_nested_data (rval=0x7f7f4058ce00, objprops=0, elements=5,
ht=0x7f7f4058ce00, classes=0x0,
    var_hash=0x7ffff2c57590, max=0x7f7f405ba4de "", p=0x7ffff2c57588) at
ext/standard/var_unserializer.re:395
#10 php_var_unserialize_ex (rval=rval@entry=0x7f7f4057d628, p=p@entry=0x7ffff2c57588,
max=max@entry=0x7f7f405ba4de "", 
    var_hash=var_hash@entry=0x7ffff2c57590, classes=classes@entry=0x0) at
ext/standard/var_unserializer.re:709
#11 0x00000000004434b0 in process_nested_data (rval=0x7f7f40e18450, objprops=1, elements=19,
ht=0x7f7f4058ce38, classes=0x0,
    var_hash=0x7ffff2c57590, max=0x7f7f405ba4de "", p=0x7ffff2c57588) at
ext/standard/var_unserializer.re:395
#12 object_common2 (rval=0x7f7f40e18450, p=0x7ffff2c57588, max=0x7f7f405ba4de "",
var_hash=0x7ffff2c57590, classes=0x0, 
    elements=<optimized out>) at ext/standard/var_unserializer.re:479
#13 0x000000000073f0a2 in php_var_unserialize_ex (rval=rval@entry=0x7f7f40e18450,
p=p@entry=0x7ffff2c57588, max=0x7f7f405ba4de "",
    var_hash=var_hash@entry=0x7ffff2c57590, classes=classes@entry=0x0) at
ext/standard/var_unserializer.re:720
#14 0x000000000073111d in zif_unserialize (execute_data=<optimized out>,
return_value=0x7f7f40e18450) at 
    /home/dev/php-src/ext/standard/var.c:1037
#15 0x0000000000878936 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER () at
/home/dev/php-src/Zend/zend_vm_execute.h:706
#16 0x00000000008302eb in execute_ex (ex=<optimized out>) at
/home/dev/php-src/Zend/zend_vm_execute.h:406
#17 0x000000000087c6cc in zend_execute (op_array=op_array@entry=0x7f7f40e80000,
return_value=return_value@entry=0x0) at 
    /home/dev/php-src/Zend/zend_vm_execute.h:450
#18 0x00000000007f37de in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0,
file_count=file_count@entry=3) at 
    /home/dev/php-src/Zend/zend.c:1396
#19 0x0000000000795090 in php_execute_script (primary_file=primary_file@entry=0x7ffff2c59ae0) at
/home/dev/php-src/main/main.c:2475
#20 0x000000000087def3 in do_cli (argc=3, argv=0x2c06a50) at
/home/dev/php-src/sapi/cli/php_cli.c:971
#21 0x0000000000448150 in main (argc=3, argv=0x2c06a50) at /home/dev/php-src/sapi/cli/php_cli.c:1338


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70033&edit=1


Thread (3 messages)

« previous php.bugs (#194248) next »