php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74382 Too many phpunit tests causing segmentation fault
Submitted: 2017-04-06 10:47 UTC Modified: 2020-11-29 04:22 UTC
Votes:4
Avg. Score:3.5 ± 1.5
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: lewis at lewnelson dot com Assigned: cmb (profile)
Status: No Feedback Package: PCRE related
PHP Version: 7.1.3 OS: ubuntu 16.04
Private report: No CVE-ID: None
 [2017-04-06 10:47 UTC] lewis at lewnelson dot com
Description:
------------
Segmentation fault occurring when running phpunit tests. Only appears to be failing when I add another test class.

Here is the output of running phpunit before adding another test class.

Total test classes: 101
Total test methods: 681

PHPUnit 5.7.12 by Sebastian Bergmann and contributors.

.............................................................   61 / 2390 (  2%)
.............................................................  122 / 2390 (  5%)
.............................................................  183 / 2390 (  7%)
.............................................................  244 / 2390 ( 10%)
.............................................................  305 / 2390 ( 12%)
.............................................................  366 / 2390 ( 15%)
.............................................................  427 / 2390 ( 17%)
.............................................................  488 / 2390 ( 20%)
.............................................................  549 / 2390 ( 22%)
.............................................................  610 / 2390 ( 25%)
.............................................................  671 / 2390 ( 28%)
.............................................................  732 / 2390 ( 30%)
.............................................................  793 / 2390 ( 33%)
.............................................................  854 / 2390 ( 35%)
.............................................................  915 / 2390 ( 38%)
.............................................................  976 / 2390 ( 40%)
............................................................. 1037 / 2390 ( 43%)
............................................................. 1098 / 2390 ( 45%)
............................................................. 1159 / 2390 ( 48%)
............................................................. 1220 / 2390 ( 51%)
............................................................. 1281 / 2390 ( 53%)
............................................................. 1342 / 2390 ( 56%)
............................................................. 1403 / 2390 ( 58%)
............................................................. 1464 / 2390 ( 61%)
............................................................. 1525 / 2390 ( 63%)
............................................................. 1586 / 2390 ( 66%)
............................................................. 1647 / 2390 ( 68%)
............................................................. 1708 / 2390 ( 71%)
............................................................. 1769 / 2390 ( 74%)
............................................................. 1830 / 2390 ( 76%)
............................................................. 1891 / 2390 ( 79%)
............................................................. 1952 / 2390 ( 81%)
............................................................. 2013 / 2390 ( 84%)
............................................................. 2074 / 2390 ( 86%)
............................................................. 2135 / 2390 ( 89%)
............................................................. 2196 / 2390 ( 91%)
............................................................. 2257 / 2390 ( 94%)
............................................................. 2318 / 2390 ( 96%)
............................................................. 2379 / 2390 ( 99%)
...........                                                   2390 / 2390 (100%)

Time: 38.33 seconds, Memory: 196.00MB

OK (2390 tests, 2804 assertions)


Once I add another test class with one new assertion just using $this->assertTrue(true) on a class which doesn't pair up on any class I have in my source code. Here is the class:

<?php

namespace Trendzer\Platform;

use PHPUnit\Framework\TestCase;

class SomethingTest extends TestCase
{
    public function testSomething()
    {
        $this->assertTrue(true);
    }
}

Here is the output now from running phpunit

Total test classes: 102
Total test methods: 682

PHPUnit 5.7.12 by Sebastian Bergmann and contributors.

.............................................................   61 / 2391 (  2%)
.............................................................  122 / 2391 (  5%)
.............................................................  183 / 2391 (  7%)
.............................................................  244 / 2391 ( 10%)
.............................................................  305 / 2391 ( 12%)
.............................................................  366 / 2391 ( 15%)
............................................Segmentation fault


Running with vendor/bin/phpunit --debug flag results in no bug and it executes successfully.

Below is output using gdb

Starting program: /usr/bin/php /home/developer/hosts/www.trendzer.localdev/application/vendor/bin/phpunit
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
PHPUnit 5.7.12 by Sebastian Bergmann and contributors.

.............................................................   61 / 2391 (  2%)
.............................................................  122 / 2391 (  5%)
.............................................................  183 / 2391 (  7%)
.............................................................  244 / 2391 ( 10%)
.............................................................  305 / 2391 ( 12%)
.............................................................  366 / 2391 ( 15%)
............................................
Program received signal SIGSEGV, Segmentation fault.
0x000055555579a0a2 in _emalloc_56 ()

output of lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial

Currently running on a virtual machine using VirtualBox.

At first I thought it might have been a new test that I had added which was specifically causing the issue, however it seems to happen regardless of where/what I call the new test. The bug also occurs when I delete an old test and keep the new test, so there are no extra test classes.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-06 11:03 UTC] lewis at lewnelson dot com
Colleague tested using php 7.1.1 using the same virtual machine setup and it worked fine. They updated to 7.1.3 and had the same error occur.
 [2017-04-06 11:20 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-04-06 11:20 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

A small repro script would be nice too.
 [2017-04-06 14:13 UTC] lewis at lewnelson dot com
-Status: Feedback +Status: Open -Package: Reproducible crash +Package: Xdebug
 [2017-04-06 14:13 UTC] lewis at lewnelson dot com
#0  0x000055555579a0a2 in _emalloc_56 ()
#1  0x00005555557c4080 in _array_init ()
#2  0x000055555568177f in php_pcre_split_impl ()
#3  0x0000555555681d95 in ?? ()
#4  0x00007ffff304671d in xdebug_execute_internal (current_execute_data=0x7ffff3815c70, return_value=0x7ffff3815c40) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:2147
#5  0x0000555555863f2c in ?? ()
#6  0x000055555580b79b in execute_ex ()
#7  0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815b90) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#8  0x000055555586446a in ?? ()
#9  0x000055555580b79b in execute_ex ()
#10 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815b30) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#11 0x000055555586446a in ?? ()
#12 0x000055555580b79b in execute_ex ()
#13 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815aa0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#14 0x0000555555863ffe in ?? ()
#15 0x000055555580b79b in execute_ex ()
#16 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815a10) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#17 0x0000555555863ffe in ?? ()
#18 0x000055555580b79b in execute_ex ()
#19 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815950) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#20 0x0000555555863ffe in ?? ()
#21 0x000055555580b79b in execute_ex ()
#22 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815890) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#23 0x0000555555863ffe in ?? ()
#24 0x000055555580b79b in execute_ex ()
#25 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff38153d0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#26 0x000055555586446a in ?? ()
#27 0x000055555580b79b in execute_ex ()
#28 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff38152b0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#29 0x000055555586446a in ?? ()
#30 0x000055555580b79b in execute_ex ()
#31 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff38151a0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#32 0x0000555555863ffe in ?? ()
#33 0x000055555580b79b in execute_ex ()
#34 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815110) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#35 0x0000555555863ffe in ?? ()
#36 0x000055555580b79b in execute_ex ()
#37 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3815010) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#38 0x0000555555863ffe in ?? ()
#39 0x000055555580b79b in execute_ex ()
#40 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814f70) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#41 0x0000555555863ffe in ?? ()
#42 0x000055555580b79b in execute_ex ()
#43 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814ec0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#44 0x0000555555863ffe in ?? ()
#45 0x000055555580b79b in execute_ex ()
#46 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814e30) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#47 0x00005555557b1d6b in zend_call_function ()
#48 0x00005555556a8c84 in ?? ()
#49 0x00007ffff304671d in xdebug_execute_internal (current_execute_data=0x7ffff3814dc0, return_value=0x7ffff3814da0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:2147
#50 0x0000555555863f2c in ?? ()
#51 0x000055555580b79b in execute_ex ()
#52 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814cd0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#53 0x0000555555863ffe in ?? ()
#54 0x000055555580b79b in execute_ex ()
#55 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814bc0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#56 0x000055555586446a in ?? ()
#57 0x000055555580b79b in execute_ex ()
#58 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff38149c0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#59 0x000055555586446a in ?? ()
#60 0x000055555580b79b in execute_ex ()
#61 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff38147e0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#62 0x000055555586446a in ?? ()
#63 0x000055555580b79b in execute_ex ()
#64 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff38146b0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#65 0x000055555586446a in ?? ()
#66 0x000055555580b79b in execute_ex ()
#67 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814580) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#68 0x000055555586446a in ?? ()
#69 0x000055555580b79b in execute_ex ()
#70 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814450) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#71 0x000055555586446a in ?? ()
#72 0x000055555580b79b in execute_ex ()
#73 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814290) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#74 0x0000555555863ffe in ?? ()
#75 0x000055555580b79b in execute_ex ()
#76 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814140) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#77 0x0000555555863ffe in ?? ()
#78 0x000055555580b79b in execute_ex ()
#79 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff38140b0) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#80 0x000055555586446a in ?? ()
#81 0x000055555580b79b in execute_ex ()
#82 0x00007ffff3045c06 in xdebug_execute_ex (execute_data=0x7ffff3814030) at /build/xdebug-Zh5NPT/xdebug-2.5.1/build-7.1/xdebug.c:1995
#83 0x00005555558665e0 in zend_execute ()
#84 0x00005555557c1ff3 in zend_execute_scripts ()
#85 0x000055555575e530 in php_execute_script ()
#86 0x0000555555868867 in ?? ()
#87 0x000055555563a94c in main ()

Here is the backtrace. I have tried to reproduce outside of the code base where it has occured, but couldn't replicate it. I've changed the package to Xdebug as it looks like this is where the issue is occurring according to the backtrace. I'll try again to see if I can get a script which will reproduce the error.
 [2017-04-06 14:16 UTC] lewis at lewnelson dot com
In case it's required the xdebug extension version is Xdebug v2.5.1
 [2017-04-06 15:15 UTC] derick@php.net
-Status: Open +Status: Feedback -Package: Xdebug +Package: PCRE related
 [2017-04-06 15:15 UTC] derick@php.net
This happens in pcre_split, which is the pcre extension. 

Your PHP doesn't have symbols available, but Xdebug does, that's why you see it so often. If you have installed PHP through Ubuntu's packages, also install the php-dev (or php-5dev, or whatever it's called), to provide a useful backtrace.
 [2017-04-06 15:23 UTC] nikic@php.net
After installing the debug symbols, could you please also provide the output of "USE_ZEND_ALLOC=0 valgrind php vendor/bin/phpunit"? (It might take a few minutes to run.)
 [2017-04-06 15:29 UTC] spam2 at rhsoft dot net
*-dev packages does *not* contain debug-symbols
they are for building extensions and contain headers and so on

https://wiki.ubuntu.com/Debug%20Symbol%20Packages
 [2017-04-07 09:36 UTC] lewis at lewnelson dot com
I installed the dbgsym packages for all of the 7.1 packages I have installed, the output from the backtrace looks a little bit more helpful, but still a lot of references to xdebug.c:1995. I'm currently still running "USE_ZEND_ALLOC=0 valgrind php vendor/bin/phpunit" and will stick the output up on pastebin once it's done.

Here is the pastebin link for the backtrace, looks easier to read on pastebin https://pastebin.com/TXBABZD5
 [2017-04-07 09:47 UTC] lewis at lewnelson dot com
Pastebin to output of "USE_ZEND_ALLOC=0 valgrind php vendor/bin/phpunit" https://pastebin.com/0445vUBM
 [2017-04-07 10:47 UTC] lewis at lewnelson dot com
-Status: Feedback +Status: Open
 [2017-04-07 10:47 UTC] lewis at lewnelson dot com
Reopened with new information
 [2020-11-16 16:48 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-11-16 16:48 UTC] cmb@php.net
Do you still experience this segfault with any of the actively
supported PHP versions[1]?  If so, does it also happen with Xdebug
disabled?

[1] <https://www.php.net/supported-versions.php>
 [2020-11-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 14:01:30 2024 UTC