|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51761 Memory Error: IPR in language scanner
Submitted: 2010-05-07 00:13 UTC Modified: 2013-02-18 00:34 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: russell dot tempero at rightnow dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
18 - 4 = ?
Subscribe to this entry?

 [2010-05-07 00:13 UTC] russell dot tempero at rightnow dot com
When running PHP through Purify, I am seeing Invalid Pointer Read (IPR) errors such as the following:

IPR: Invalid pointer read:
  * This is occurring while in thread 8075:
    lex_scan       [zend_language_scanner.c:3174]
    zendlex        [zend_compile.c:4950]
    zendparse      [zend_language_parser.c:3280]
    compile_file   [zend_language_scanner.l:343]
    rnt_compile_file [rnt_opcode_cache.c:1008]
    compile_filename [zend_language_scanner.l:386]
  * Reading 1 byte from 0xf735f332 between the heap and the stack.

It appears that script files are memory mapped and then a cursor pointer is used to iterate over the mapped memory. The problem is that the cursor pointer is not properly checked when reaching the end of the file and memory values are read that are not part of the mapped memory. I manually fixed one case of this (see attached diff). However, there are others.

It looks like this file is generated (using flex?) so this is probably not actually a PHP issue. However, I thought I would start here. Let me know if this needs to be submitted to somebody else.


scanner_ipr.diff (last revision 2010-05-06 22:13 UTC by russell dot tempero at rightnow dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-07 00:21 UTC] russell dot tempero at rightnow dot com
Here is some useful debug information if you wish to trace exactly where the IPRs are happening:

state: 476 char: ? addr: 0xf1c7885e
state: 140 char: ? addr: 0xf1c7885e
state: 121 char: ? addr: 0xf1c7885e
state: -1 char: ? addr: 0xffce705b
state: 166 char: ? addr: 0xf1c7885e
state: 201 char: > addr: 0xf1c7885f
state: 203 char:
 addr: 0xf1c78860
RUSSELL: YYCURSOR: 0xf1c78860 YYLIMIT: 0xf1c78861
state: 202 char:
state: 0 char:
state: 4 char:
state: 3 char:
RUSSELL: returning 0 in yy3
 [2010-05-08 11:58 UTC]

You should change the grammar in zend_language_scanner.l instead of the .c file which is generated based on the contains from the .l file. Else the patch looks good
 [2010-05-12 09:34 UTC]
-Status: Open +Status: Feedback
 [2010-05-12 09:34 UTC]
This should have been set to feedback, shouldn't it?
 [2010-05-13 19:11 UTC] russell dot tempero at rightnow dot com
-Status: Feedback +Status: Open
 [2010-05-13 19:11 UTC] russell dot tempero at rightnow dot com
If you are confident that these errors can be fixed by altering the grammar, I'll do some more looking to see what I can come up with. This is probably going to take me a little while though.

Based on what I was seeing, I thought this was more a problem with how flex generated the scanner from the grammar.
 [2010-06-20 16:33 UTC]
We are using re2c instead of flex for 5.3+.
 [2010-08-01 23:28 UTC]
-Status: Open +Status: Feedback
 [2010-08-01 23:28 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 00:01:33 2024 UTC