View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001754 | Xdebug | Code Coverage | public | 2020-03-05 09:29 | 2022-11-05 09:51 |
Reporter | juancasanova | Assigned To | derick | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | not fixable | ||
Product Version | 2.9.2 | ||||
Summary | 0001754: Incorrect code coverage in nested ifs | ||||
Description | I have made a simple script like this:
When using Xdebug's code coverage calculation, it shows that both lines 3 and 5 are beign executed although it is obviously impossible. I have actually tested this with PHP 7.1.33, 7.2.28, 7.3.15 and 7.4.3 (all with Xdebug 2.9.2). | ||||
Steps To Reproduce | I have attached a small script that replicates the failure every time. | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
Operating System | Ubuntu 18.0.4 | ||||
PHP Version | 7.4.0-7.4.4 | ||||
|
I've analysed your test file with vld, and that gives me the following output:
compiled vars: !0 = $a, !1 = $b, !2 = $c line #* E I O op fetch ext return operands 3 0 E > EXT_STMT After the $a = 0 (line 7, opcode 10), PHP generates code to jump to the end of the whole if(true) { $a = 0 } else { $a = 1 } section. (line 7, opcode 11). PHP has generated a jump instruction to immediately jump away from that (line 9, opcode 14). Unfortunately, this means that for PHP's internals, there is now code being executed on line 9, even though when looking at the script, this makes no sense. Xdebug can't really change was PHP generates internally, so I'm having to close this as "Not Fixable". I'll see if I can talk to the PHP internals folks if they can see a way on how to fix this in PHP. |
|
the solution is to enable opcache for CLI (opcache.enable_cli=1), then the l5 and l8 are correctly pruned/excluded |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-03-05 09:29 | juancasanova | New Issue | |
2020-03-05 09:29 | juancasanova | File Added: test.php | |
2020-03-05 13:09 | derick | Description Updated | |
2020-03-06 12:06 | derick | Assigned To | => derick |
2020-03-06 12:06 | derick | Status | new => resolved |
2020-03-06 12:06 | derick | Resolution | open => not fixable |
2020-03-06 12:06 | derick | Note Added: 0005275 | |
2022-11-05 09:51 | videoice | Note Added: 0006437 |