php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45029 POST requests have an emalloc leak
Submitted: 2008-05-17 17:39 UTC Modified: 2008-05-19 21:57 UTC
From: rasmus@php.net Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.3CVS-2008-05-17 (CVS) OS: Linux/FreeBSD
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: rasmus@php.net
New email:
PHP Version: OS:

 

 [2008-05-17 17:39 UTC] rasmus@php.net
Description:
------------
Adding a bug for this so we can track it.

The leak size isn't constant even though the post data size in this example is constant, and the returned data (a dns error, presumably) is the same.  Seems like there is something weird in our postfield handling code in the curl extension.  Note also that it stabilizes somehow, although this is an extremely simplified version of a long-running command-line script that seems to grow on each post with wildly varying post data. 

Reproduce code:
---------------
<?php
function curl($post) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "www.fdhfkdsslak.bogus");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  if($post) {
    curl_setopt($ch, CURLOPT_POST, 1);
    for($args='',$i=0;$i<75;$i++) $args .= "a=$i&";
    curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
    unset($args);
  }
  curl_exec($ch);
  curl_close($ch);
}
echo "start ".memory_get_usage()."\n";
for($i=0;$i<10;$i++) {
  curl(0);
  echo "GET ".memory_get_usage()."\n";
}
for($i=0;$i<10;$i++) {
  curl(1);
  echo "POST ".memory_get_usage()."\n";
}
?>


Expected result:
----------------
No memory_usage increase from one POST request to the next.

Actual result:
--------------
start 326616
GET 327256
GET 327276
GET 327276
GET 327276
GET 327276
GET 327276
GET 327276
GET 327276
GET 327276
GET 327276
POST 327516
POST 327588
POST 327652
POST 327712
POST 327892
POST 328064
POST 328228
POST 328384
POST 328528
POST 328628 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-19 21:57 UTC] rasmus@php.net
Never mind.  The combination of an infinitely growing static array and some caching in the memory manager made this look like a PHP bug when it actually wasn't.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 16:01:26 2019 UTC