View Issue Details

IDProjectCategoryView StatusLast Update
0001799XdebugCode Coveragepublic2021-08-26 17:03
Reporterdvdoug Assigned Toderick  
PrioritynormalSeveritymajorReproducibilitysometimes
Status acknowledgedResolutionopen 
Product Version2.9.6 
Target Version3.2dev 
Summary0001799: Inconsistent output of branch/path data when running under Opcache
DescriptionWhen running under Opcache, the first run returns a full set of data. Subsequent runs do not.

Specifically in the attached testcase, there are 2 entries in the function data on the first call "SomeClass->getItems" and "{main}". In the second/third/etc invocations the only entry is for "{main}"
Steps To ReproduceWith opcache.enable=1, opcache.enable_cli=1

SomeClass.php
<?php


class SomeClass
{
    public function getItems()
    {
        return 'foo';
    }

}


Test script (please run twice)
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE | XDEBUG_CC_BRANCH_CHECK);
require_once 'SomeClass.php';
$class = new SomeClass();

print_r(xdebug_get_code_coverage());
Additional InformationThis minimal testcase does not include a call to the method, but this reproduces for me even if you do
TagsNo tags attached.
Operating SystemWindows 10
PHP Version7.4.0-7.4.4

Activities

derick

2021-08-26 17:00

administrator   ~0005992

Last edited: 2021-08-26 17:03

Hi!

I have now finally sat down to have a good look at this, as well as some
other issues. In order to fix this, I had to split the analysing part
(scanning opcodes) and collecting data during execution, into two separate
data structures. This work is part of the improve-code-coverage
<https://github.com/derickr/xdebug/tree/improve-code-coverage> branch.

The good news is that this fixes the problem, and several related parts.

The bad news is that this makes code coverage twice as slow.

This is likely because there are now more data structures, and hence memory
allocations and frees are involved, but I've not been able to pinpoint the
real cause, nor have I come up with some plan to address this new slow down.

I therefore don't want to merge this branch yet, and I'm moving the target
for this Xdebug 3.2. But, please try out the new branch, as it's possible
that there are still some pending issues.

cheers,
Derick

Issue History

Date Modified Username Field Change
2020-06-15 16:19 dvdoug New Issue
2020-06-19 15:13 derick Assigned To => derick
2020-06-19 15:13 derick Status new => acknowledged
2021-03-17 08:52 derick Target Version => 3.1dev
2021-08-26 17:00 derick Target Version 3.1dev => 3.2dev
2021-08-26 17:00 derick Note Added: 0005992
2021-08-26 17:03 derick Note Edited: 0005992