php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76481 XMLReader::expand leaks memory over HTTP (but not over CLI)
Submitted: 2018-06-15 09:42 UTC Modified: 2018-06-22 14:35 UTC
From: tom dot denbraber at moxio dot com Assigned:
Status: Duplicate Package: XML Reader
PHP Version: 7.2.6 OS: Debian 9.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tom dot denbraber at moxio dot com
New email:
PHP Version: OS:

 

 [2018-06-15 09:42 UTC] tom dot denbraber at moxio dot com
Description:
------------
XMLReader::expand does not free its allocated memory.
When executing the test script below using the CLI, the memory usage is as expected. However, when serving the same script over HTTP (via Apache or nginx), the XMLreader::expand function does not free its memory. For larger XMLs, this is a problem.

Because the problem only occurs when serving the script over HTTP, I do not know whether this is a 'Network Functions'-issue, and 'XML Reader'-issue or a 'Web Server'-issue. Feel free to re-categorize.

Test script:
---------------
<?php
$xml_string = "<?xml version=\"1.0\"?>
<items>";
for ($i = 0; $i < 50000; $i++) {
	$xml_string .= sprintf("<item id=\"bk%d\"></item>", $i);
}
$xml_string .= "</items>";
$reader = new XMLReader();
$reader->XML($xml_string);

print memory_get_usage() . "\n";
while ($reader->read() === true) {
	$node = $reader->expand();
}
print memory_get_usage() . "\n";


Expected result:
----------------
The first and second memory-usage prints should be roughly equal to each other (this happens when executing the script using the CLI).

Actual result:
--------------
When executed over HTTP, the second memory usage is a lot higher than the memory usage that was printed first. For the given script, often up to 66% higher.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-15 11:36 UTC] tom dot denbraber at moxio dot com
I also tested the situations mentioned above in PHP 7.1.18, but the bug does not occur in that version.
 [2018-06-22 13:17 UTC] tom dot denbraber at moxio dot com
This problem is probably related to https://bugs.php.net/bug.php?id=76520.
 [2018-06-22 14:35 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2018-06-22 14:35 UTC] nikic@php.net
I've verified that this issue is indeed resolved by the fix for bug #76520, so closing this as a duplicate of that issue.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 16 04:01:26 2019 UTC