php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74234 Op Code is generated on wrong line
Submitted: 2017-03-10 17:42 UTC Modified: 2017-03-17 17:44 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: scott at exussum dot co dot uk Assigned: nikic (profile)
Status: Assigned Package: *General Issues
PHP Version: 7.1.2 OS: Linux (ubuntu 16.10)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: scott at exussum dot co dot uk
New email:
PHP Version: OS:

 

 [2017-03-10 17:42 UTC] scott at exussum dot co dot uk
Description:
------------
The op code for the jmp seems to be generated against the wrong line for the continue. (See script below)

 6 9 > EXT_STMT 
        10 > JMPZ <false>, ->13
   7 11 > EXT_STMT 
        12 > JMP ->8
        13 > > JMP ->8
        14 > FE_FREE $3


Pasted from Derick
HP unfortunately doesn't reset the line numbers for some of the generated code:

   6 9 > EXT_STMT 
        10 > JMPZ <false>, ->13
   7 11 > EXT_STMT 
        12 > JMP ->8
        13 > > JMP ->8
        14 > FE_FREE $3

The JMP in line 12 (and line 13) is generated for line 7, and not 8. This is something that needs to be fixed in PHP itself

See https://bugs.xdebug.org/view.php?id=1405#c4232 for more info



Test script:
---------------
foreach([1,2] as $value) {
    if (false) {
        continue;
    }
}




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-14 04:42 UTC] laruence@php.net
-Assigned To: +Assigned To: nikic
 [2017-03-14 04:42 UTC] laruence@php.net
I don't see how to get the last line no of a block in current AST..

@nikic, what do you think?
 [2017-03-17 17:44 UTC] nikic@php.net
Storing the end lineno will increase the size of most AST nodes by 64 bytes. Would have to measure how much impact that has on total memory usage.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Apr 18 15:01:24 2021 UTC