php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76346 memory leak
Submitted: 2018-05-16 01:26 UTC Modified: 2021-01-15 22:53 UTC
Votes:10
Avg. Score:4.4 ± 0.8
Reproduced:10 of 10 (100.0%)
Same Version:3 (30.0%)
Same OS:7 (70.0%)
From: vagiz at kaifas dot lt Assigned: cmb (profile)
Status: Closed Package: cURL related
PHP Version: 7.2.5 OS: CentOS 8
Private report: No CVE-ID: None
 [2018-05-16 01:26 UTC] vagiz at kaifas dot lt
Description:
------------
system memory keeps growing when php infinity loop is used with curl inside

Test script:
---------------
<?php
while (1) {
    $curl_handle = curl_init();
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 40);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20180101 Firefox/60.1');
    curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl_handle, CURLOPT_URL, 'http://example.com');
    $test = curl_exec($curl_handle);
    curl_close($curl_handle);
    unset($test, $curl_handle);
}
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-16 01:30 UTC] vagiz at kaifas dot lt
My php is from remi http://rpms.remirepo.net/enterprise/remi-release-7.rpm
 [2018-05-16 01:52 UTC] vagiz at kaifas dot lt
My server versions:
PHP 5.6.36 (cli) (built: Apr 25 2018 09:44:45)
PHP 7.0.30 (cli) (built: Apr 24 2018 20:40:19) ( NTS )
PHP 7.1.17 (cli) (built: Apr 25 2018 07:24:50) ( NTS )
PHP 7.2.5 (cli) (built: Apr 24 2018 19:12:06) ( NTS )

all of them have the same bug
 [2019-03-27 07:49 UTC] token0801 at qq dot com
I see these functions' calling in interval.c: 
60 timelib_apply_localtime(one, 0);
61 timelib_apply_localtime(two, 0);

When I set 2nd param to 1, the result is correct. But I don't know this modifying whether effect other functions or not.

timelib_apply_localtime(one, 1);
timelib_apply_localtime(two, 1);
 [2021-01-13 11:07 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-01-13 11:07 UTC] cmb@php.net
Does this still happen with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-01-15 22:50 UTC] vagiz at kaifas dot lt
-Status: Feedback +Status: Assigned -Operating System: CentOS 7 +Operating System: CentOS 8
 [2021-01-15 22:50 UTC] vagiz at kaifas dot lt
Re-tested versions:

PHP 8.0.1 (cli) (built: Jan  5 2021 13:54:54) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies

PHP 7.4.14 (cli) (built: Jan  5 2021 10:45:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies

PHP 7.3.26 (cli) (built: Jan  5 2021 10:36:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.26, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.26, Copyright (c) 1999-2018, by Zend Technologies


on CentOS 8;

I can confirm - no memory leak after running the same script for 30mins+.
Let me know if any help needed, otherwise I think we can close this ticket.
Good job PHP team!
 [2021-01-15 22:53 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2021-01-15 22:53 UTC] cmb@php.net
Thanks for re-checking!  I think we can close this ticket now. :)
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jan 22 22:01:24 2021 UTC