php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75306 Memleak in SoapClient
Submitted: 2017-10-03 09:00 UTC Modified: 2018-11-04 11:04 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: valov at mtsbank dot ru Assigned:
Status: Verified Package: SOAP related
PHP Version: 7.1.10 OS: RHEL 6
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-10-03 09:00 UTC] valov at mtsbank dot ru
Description:
------------
Memleak in SoapClient detected, in test script after few seconds you will get error: "Allowed memory size exhausted".

Test script:
---------------
<?php
while(true) {
  $client = new SoapClient("test.wsdl");
}
?>

You can use any test.wsdl specification, for example https://www.tutorialspoint.com/wsdl/wsdl_example.htm


Patches

fix-refcounting (last revision 2018-11-04 11:04 UTC by cmb@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-01 21:10 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2018-01-01 21:10 UTC] nikic@php.net
Can reproduce with soap.wsdl_cache_enabled=0.
 [2018-11-04 11:04 UTC] cmb@php.net
In this case, a new stream context is allocated[1], converted to a
zval[2] which increases the refcount, but the refcount is only
decreased once[3], resulting in the reported memory leak.  So not
increasing the refcount when converting to a zval would solve this
issue.  However, if a stream context is passed in the $options
array, its refcount has to be increased to avoid premature
freeing.

[1] <https://github.com/php/php-src/blob/php-7.3.0RC4/ext/soap/php_sdl.c#L3238>
[2] <https://github.com/php/php-src/blob/php-7.3.0RC4/ext/soap/php_sdl.c#L3303>
[3] <https://github.com/php/php-src/blob/php-7.3.0RC4/ext/soap/php_sdl.c#L3318>
 [2018-11-04 11:04 UTC] cmb@php.net
The following patch has been added/updated:

Patch Name: fix-refcounting
Revision:   1541329477
URL:        https://bugs.php.net/patch-display.php?bug=75306&patch=fix-refcounting&revision=1541329477
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 18:01:38 2019 UTC