View Issue Details

IDProjectCategoryView StatusLast Update
0001180XdebugCode Coveragepublic2017-01-05 13:35
Reporterjaydiablo Assigned Toderick  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSCentOSOS Version6
Product Version2.3.3 
Fixed in Version2.5.1 
Summary0001180: Running coverage on tests that use ZF1's controller test library segfault
Description

Have a suite that uses Zend Framework 1's Controller Testing framework. Tests run fine without coverage enabled (PHPUnit 4.1 and 4.8), but as soon as coverage is enabled, if any tests in the run hit the ZF1 controller test framework, a segfault is encountered.

Here's error in log:

php[4398]: segfault at 31c7000 ip 00007f3b3b48bc01 sp 00007ffdb66c6a80 error 4 in xdebug.so[7f3b3b47a000+36000]

I was able to test with Xdebug 2.3.3 and 2.3.3 (from Remi Repo). Both exhibited this behavior.

Xdebug 2.2.4 (directly from PECL) does not (the only reason for choosing this version was because it was the last known working version on my system before I updated to 2.3.3).

Steps To Reproduce

For me, and others on my team, it was as simple as running code coverage on any code that uses the ZF1 Controller Tests.

I'll try to put together a simple test case soon and update this ticket.

Additional Information

PHP 5.5.28 (cli) (built: Aug 6 2015 08:53:05)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans

TagsNo tags attached.
Operating SystemCentOS Linux 6
PHP Version5.1.0

Activities

jaydiablo

2015-08-24 21:24

reporter   ~0003166

"I was able to test with Xdebug 2.3.3 and 2.3.3 (from Remi Repo)."

That should be "2.3.3 and 2.3.2".

jaydiablo

2015-08-24 21:32

reporter   ~0003167

Just tried 2.3.2 from PECL, which also segfaults:

PHPUnit 4.8.6 by Sebastian Bergmann and contributors.

Segmentation fault (core dumped)

Though, I notice that 2.3.3 supposedly fixed a crash on coverage reports. Is 2.3.3 not stable in PECL yet?

derick

2015-11-09 01:58

administrator   ~0003213

Can you provide step-by-step instructions as to how to reproduce this — including installing anything I might not have? Expect me to have an empty system with only PHP and Xdebug setup - and know nothing about ZF.

jaydiablo

2015-11-12 19:46

reporter   ~0003227

Derick, I took some time to put a test case together that mimics the actual case that we were seeing the best I could.

While setting up this test case, I found that it may not just be Xdebug + ZF1 Controller tests, but actually something to do with stopping and starting coverage (this is something that we do in some of our suites to speed up execution times during fixture loading and such). The sample test case I setup includes these stops and starts, and if you were to remove them, the tests pass fine. I am unsure why the stops/starts don't cause issues in our tests that don't hit the ZF1 Controller testing code, perhaps they're called differently in those tests.

Here's the repo: https://github.com/jaydiablo/xdebug-test-case

I mention in the readme how to reproduce the segfault, let me know if you require anything else to take a look at this.

Oh, also, I should mention that when I was testing where the segfault happened I would occasionally get this output:

glibc detected php: double free or corruption (out): 0x00000000167244b0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x38fb475e66]
/lib64/libc.so.6[0x38fb4789ba]
/usr/lib64/php/modules/xdebug.so(xdebug_code_coverage_end_of_function+0xc9)[0x7f52e6746e79]
/usr/lib64/php/modules/xdebug.so(xdebug_execute_ex+0x791)[0x7f52e6742be1]
php[0x663b6d]
php(execute_ex+0x38)[0x654f58]
php(dtrace_execute_ex+0x8e)[0x5d0d0e]
/usr/lib64/php/modules/xdebug.so(xdebug_execute_ex+0x5f3)[0x7f52e6742a43]

TRUNCATED

I'll add a full copy of this trace to the repo in case it sheds some light on anything.

Thanks!

derick

2015-11-12 20:02

administrator   ~0003228

Cheers, I can reproduce the issue with your test case.

aripringle

2016-08-05 22:07

reporter   ~0003669

Hello,

I'm a colleague of the OP, and we were revisiting this as we move towards upgrading our systems to PHP7. I was able to simplify the test suite provided, which you can see here:

https://github.com/aripringle/xdebug-test-case/tree/simplification

The failure scenario seems very specific to our original implementation - calling a static method, which in turn calls another static method, which resumes code coverage and then sets a static property. I added some slight variations that don't fail:

  • A passing test in TheTest.php, which calls the exact same static methods as the failing test, the only difference being that it bypasses the intermediary static method.
  • A separate TestCase (NoStaticPropertyOnResumeTest.php) that passes, the only difference being that it the "resumeCodeCoverage" method does not change the value of the static property after resuming code coverage.

Also of note is that the segfault only happens when resuming coverage with the XDEBUG_CC_UNUSED flag.

derick

2016-08-10 15:15

administrator   ~0003672

I still can reproduce it, but finding the problem is a whole lot harder as there is so much code involved.

derick

2017-01-05 13:35

administrator   ~0004158

Fixed for Xdebug 2.5.1.

Issue History

Date Modified Username Field Change
2015-08-24 21:20 jaydiablo New Issue
2015-08-24 21:24 jaydiablo Note Added: 0003166
2015-08-24 21:32 jaydiablo Note Added: 0003167
2015-11-09 01:58 derick PHP Version 5.5.20-5.5.25 => 5.1.0
2015-11-09 01:58 derick Note Added: 0003213
2015-11-09 01:58 derick Assigned To => derick
2015-11-09 01:58 derick Status new => feedback
2015-11-12 19:46 jaydiablo Note Added: 0003227
2015-11-12 19:46 jaydiablo Status feedback => assigned
2015-11-12 20:02 derick Note Added: 0003228
2015-11-20 17:43 derick Target Version => 2.4.1
2016-07-31 12:35 derick Category Debug client (console) => debugclient (debugging tool)
2016-07-31 12:35 derick Category debugclient (debugging tool) => (No Category)
2016-08-01 20:29 derick Target Version 2.4.1 => 2.4.2
2016-08-05 22:07 aripringle Note Added: 0003669
2016-08-10 15:15 derick Note Added: 0003672
2016-11-12 16:54 derick Target Version 2.4.2 => 2.5.0RC2
2016-11-12 16:55 derick Target Version 2.5.0RC2 => 2.5.0dev
2016-12-04 18:34 derick Target Version 2.5.0dev =>
2016-12-12 00:10 derick Category (No Category) => Code Coverage
2016-12-12 11:17 derick Status assigned => acknowledged
2017-01-05 13:35 derick Note Added: 0004158
2017-01-05 13:35 derick Status acknowledged => closed
2017-01-05 13:35 derick Resolution open => fixed
2017-01-05 13:35 derick Fixed in Version => 2.5.1