php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66151 Memory leak when SOAP fails to process a WSDL file
Submitted: 2013-11-22 17:22 UTC Modified: -
Votes:16
Avg. Score:3.6 ± 1.8
Reproduced:10 of 10 (100.0%)
Same Version:0 (0.0%)
Same OS:6 (60.0%)
From: askalski at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.4Git-2013-11-22 (Git) OS: Linux
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: askalski at gmail dot com
New email:
PHP Version: OS:

 

 [2013-11-22 17:22 UTC] askalski at gmail dot com
Description:
------------
The PHP SOAP module leaks memory when it fails to parse a WSDL file.  This leaked memory is not recovered between requests (mod_php).


Test script:
---------------
Download the following file into your script directory before testing:

http://www.paypalobjects.com/wsdl/PayPalSvc.wsdl

Do NOT download the dependent .xsd files (if they already exist in your directory, remove them.)  The missing .xsd files will cause the WSDL parse failure which is essential to reproducing the memory leak.

PHP should be configured as an Apache module (mod_php).

<?php
$s = new soapclient("PayPalSvc.wsdl");
?>

Request the script many times with curl or Apache Bench.  Monitor memory/swap usage.  (Be prepared to stop the test before it exhausts all of your memory.  This will happen very quickly.)


Expected result:
----------------
Apache worker memory usage should stay relatively constant.

Actual result:
--------------
Because of the leak, memory usage grows rapidly.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-27 15:27 UTC] yar dot onish at gmail dot com
I have the same issue on PHP 7.0.14.
Have to notice, the problem connected not only with WSDL loading but with any SoapFault.
Also, it is not only php_mod realted, can be reproduced in CLI.

Looks like after SoapFault happens GC stops to work at all.
Every single call of gc_collect_cycles() returns 0 instead of 1.

Test:
----------------------------------------
<?php
class MyClass
{
    public $me;
    public function __construct()
    {
        $this->me = $this;
    }
}

$b = memory_get_usage();

try {
    $s = new SoapClient("dummy.wsdl");
} catch (\Exception $e) {
    echo $e->getMessage() . PHP_EOL;
}

for ($i = 0; $i < 3; $i++)
{
    new MyClass();
    echo gc_collect_cycles() . PHP_EOL;
}

var_dump(memory_get_usage() - $b);


Expected result:
------------------------------------------
SOAP-ERROR: Parsing WSDL: Couldn't load from 'some.wsdl' : failed to
load external entity "some.wsdl"

int(0)



Actual result:
------------------------------------------
SOAP-ERROR: Parsing WSDL: Couldn't load from 'some.wsdl' : failed to load external entity "some.wsdl"

int(4168)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 14:01:29 2024 UTC