Repository navigation
SoapServer memory leak #19784
Copy link
Copy link
Closed
Description
Description
The following code:
<?php
$v_5237 = 'irrelevant';
$v_5256 = 'zpHOks6TzpTOlc6WzpfOmM6ZzprOm86czp3Ons6fzqDOoc6jzqTOpc6mzqfOqM6p';
$v_5257 = base64_decode($v_5256,);
$v_5238 = array('encoding' => $v_5257,);
try{
$v_5254 = 'zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J';
$v_5255 = base64_decode($v_5254,);
$v_5238 = array('encoding' => $v_5257,);
$v_5245 = new SoapServer($v_5255,$v_5238,);
}
catch (Throwable $e){
}Resulted in this output:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>WSDL</faultcode><faultstring>SOAP-ERROR: Parsing WSDL: Couldn't load from 'αβγδεζηθικλμνξοπρστυφχψω' : failed to load external entity "αβγδεζηθικλμνξοπρστυφχψω"
</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
=================================================================
==53==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x6810bd in malloc (/home/php+0x6810bd)
#1 0x14c8df6f85ba (/lib/x86_64-linux-gnu/libxml2.so.2+0x3d5ba)
Indirect leak of 32640 byte(s) in 1 object(s) allocated from:
#0 0x6810bd in malloc (/home/php+0x6810bd)
#1 0x14c8decc27e6 in __gconv_open iconv/./iconv/gconv_open.c:127:36
#2 0x14c8decc22b7 in iconv_open iconv/./iconv/iconv_open.c:39:13
#3 0x60200001a24f (<unknown module>)
Indirect leak of 32640 byte(s) in 1 object(s) allocated from:
#0 0x6810bd in malloc (/home/php+0x6810bd)
#1 0x14c8decc27e6 in __gconv_open iconv/./iconv/gconv_open.c:127:36
#2 0x14c8decc22b7 in iconv_open iconv/./iconv/iconv_open.c:39:13
#3 0x6060000618df (<unknown module>)
Indirect leak of 416 byte(s) in 2 object(s) allocated from:
#0 0x6810bd in malloc (/home/php+0x6810bd)
#1 0x14c8deccd9d6 in __gconv_lookup_cache iconv/./iconv/gconv_cache.c:365:36
Indirect leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x6810bd in malloc (/home/php+0x6810bd)
#1 0x14c8decc276c in __gconv_open iconv/./iconv/gconv_open.c:77:28
#2 0x14c8decc22b7 in iconv_open iconv/./iconv/iconv_open.c:39:13
#3 0x60200001a24f (<unknown module>)
Indirect leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x6810bd in malloc (/home/php+0x6810bd)
#1 0x14c8decc276c in __gconv_open iconv/./iconv/gconv_open.c:77:28
#2 0x14c8decc22b7 in iconv_open iconv/./iconv/iconv_open.c:39:13
#3 0x6060000618df (<unknown module>)
Indirect leak of 49 byte(s) in 1 object(s) allocated from:
#0 0x6810bd in malloc (/home/php+0x6810bd)
#1 0x14c8df79a912 (/lib/x86_64-linux-gnu/libxml2.so.2+0xdf912)
SUMMARY: AddressSanitizer: 66025 byte(s) leaked in 8 allocation(s).
PHP Version
nightly
Operating System
ubuntu 22.04
Reactions are currently unavailable
Activity
devnexen commentedon Sep 10, 2025
not sure that is a php issue even less a soap one.
devnexen commentedon Sep 10, 2025
Ok things are clearer now
ndossche commentedon Sep 12, 2025
This is also conceptually very close to #19788 and #14044
The root cause is that an error bailout happens if the wsdl filename is not found, which skips the free_obj hooks which means that the persistent memory from libxml is not freed here.
Fortunately it's usually only triggerable in exceptional cases...
It could be triggerable by network availability though and we already cater for persistent leaks caused by non-programming bugs, so I guess I'll have to handle it here.
Fix phpGH-19784: SoapServer memory leak
Fix GH-19784: SoapServer memory leak
Merge branch 'PHP-8.3' into PHP-8.4
Merge branch 'PHP-8.4'