View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001541 | Xdebug | Code Coverage | public | 2018-03-26 14:42 | 2019-08-26 12:37 |
Reporter | theoboldt | Assigned To | derick | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | duplicate | ||
Platform | Linux | OS | Ubuntu | OS Version | 16.04.1 |
Product Version | 2.6.0 | ||||
Target Version | 2.8.0dev | Fixed in Version | 2.8.0beta2 | ||
Summary | 0001541: switch/case case is not covered when using php-fpm php 7.0 | ||||
Description | When executing switch/case within a function, no case line of executed cases is marked as covered, except the following:
The lines are marked as covered as expected when the same file is executed via CLI using same php/xdebug version. {code}
{code} When executing above code via CLI, following output is generated:
{code} When executing above code via Apache 2 (Server API: FPM/FastCGI, PHP API: 20151012, PHP Extension: 20151012) the output differs significantly for line 8 and 11:
{code} | ||||
Steps To Reproduce | Execute provided using php 7.0.28 snipped via php-fpm and via cli as well, compare results | ||||
Tags | PHP7, php7.2 | ||||
Attached Files | switch_case.php (827 bytes)
<?php function a($option) { switch ($option) { case 'first': $option .= '_covered'; break; case 'second': $option .= '_covered'; break; case 'third': $option .= '_covered'; break; default: $option .= '_covered'; break; } return $option; } xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); a('first'); a('second'); a('third'); a('default'); $coverage = xdebug_get_code_coverage(); xdebug_stop_code_coverage(); //EVALUATE (not part of proof) echo "<pre>\n"; print_r( [ 'phpversion(\'xdebug\')' => phpversion('xdebug'), 'phpversion()' => phpversion(), 'php_sapi_name()' => php_sapi_name() ] ); print_r($coverage); ?> | ||||
Operating System | |||||
PHP Version | 7.0.25-7.0.29 | ||||
|
Still reproducible using xdebug 2.6.1. |
|
Do you have opcache installed and enabled for the PHP-FPM install? |
|
Result having opcache enabled: Result having opcache disabled: |
|
Also reproducible using php 7.2: opcache enabled: opcache disabled: |
|
I will have a look at this after Xdebug 2.7.0 has been released. I haven't reproduced it yet, so will leave the issue in "acknowledged" for now. |
|
I can't reproduce this - is this still causing you trouble? |
|
Still reproducible using Xdebug 2.7.2, PHP FPM, having opcache enabled:
Still reproducible using Xdebug 2.7.2, PHP FPM, having opcache disabled:
|
|
I just spend another two hours setting this up in a new and pristine VM with Ubuntu 18.04.2 LTS, which from what I can see is the exact same environment. The result is: Opcache disabled:
Opcache enabled:
As you can see, I still can't reproduce this. I installed Xdebug from source and I also tried the php-xdebug package (Xdebug 2.6.0), and I still get the same result. There must be something different in your environment, although I can't see what would impact this. Is there any chance you can set-up a VM or something that shows the problem and you can give me access to? |
|
We identified the configuration responsible for the error. If the configuration contains xdebug.coverage_enable = 0, the error occurs. If the related configuration option is put in comments, no error occurs. If xdebug.coverage_enable = 1is configured, no error occurs. I'd say that this should still be regarded as error, since it prevents users from collecting code coverage data of only specific snippets. We created a docker image which can be used to reproduce the error. When docker container is loaded and running, the container provides a web server at port 80. Proof can be found via /index.php. The bzip2 compressed docker image can be accessed within 7 days via: https://send.firefox.com/download/9b4b0fd39342cbca/#s7XDxm7K7sSWRmHY113vlQ |
|
Oh! If you turn off I can reproduce it when that configuration setting, so feel free to remove your Docker container. |
|
Fixed in 2.8.0beta2, by making sure there is a warning when you want to use code coverage when xdebug.code_coverage=0 (and duplicate of 0001540) |
Date Modified | Username | Field | Change |
---|---|---|---|
2018-03-26 14:42 | theoboldt | New Issue | |
2018-03-26 14:42 | theoboldt | File Added: switch_case.php | |
2018-03-26 14:48 | theoboldt | Tag Attached: PHP7 | |
2018-11-15 10:54 | theoboldt | Note Added: 0004724 | |
2018-12-06 12:11 | derick | Note Added: 0004749 | |
2018-12-06 12:11 | derick | Assigned To | => derick |
2018-12-06 12:11 | derick | Status | new => feedback |
2018-12-06 15:21 | theoboldt | Note Added: 0004750 | |
2018-12-06 15:21 | theoboldt | Status | feedback => assigned |
2018-12-06 15:33 | theoboldt | Note Added: 0004753 | |
2019-01-22 22:27 | derick | Note Added: 0004834 | |
2019-01-22 22:27 | derick | Status | assigned => acknowledged |
2019-01-22 22:27 | derick | Target Version | => 2.7.0dev |
2019-06-28 11:16 | derick | Target Version | 2.7.0dev => 2.8.0dev |
2019-07-15 16:36 | derick | Status | acknowledged => feedback |
2019-07-15 16:36 | derick | Note Added: 0005061 | |
2019-07-16 09:43 | theoboldt | Note Added: 0005063 | |
2019-07-16 09:43 | theoboldt | Status | feedback => assigned |
2019-07-16 09:45 | theoboldt | Tag Attached: php7.2 | |
2019-07-19 11:29 | derick | Status | assigned => feedback |
2019-07-19 11:29 | derick | Note Added: 0005071 | |
2019-07-19 11:29 | derick | Note Edited: 0005071 | |
2019-07-19 14:04 | theoboldt | Note Added: 0005079 | |
2019-07-19 14:04 | theoboldt | Status | feedback => assigned |
2019-07-19 14:25 | derick | Note Added: 0005080 | |
2019-07-19 14:25 | derick | Status | assigned => confirmed |
2019-07-27 22:39 | derick | Status | confirmed => resolved |
2019-07-27 22:39 | derick | Resolution | open => duplicate |
2019-07-27 22:39 | derick | Fixed in Version | => 2.8.0dev |
2019-07-27 22:39 | derick | Note Added: 0005095 | |
2019-07-27 22:39 | derick | Relationship added | duplicate of 0001540 |
2019-08-26 12:37 | derick | Status | resolved => closed |
2019-08-26 12:37 | derick | Fixed in Version | 2.8.0dev => 2.8.0beta2 |