[php-src] Issue #10026: Garbage collection stops after exception in SoapClient
| From: | abienvenu | Date: | Wed, 30 Nov 2022 17:40:34 +0000 |
| Subject: | [php-src] Issue #10026: Garbage collection stops after exception in SoapClient | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243005@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10026
Author: abienvenu
### Description
The following code:
```php
<?php
class A
{
public $b;
}
class B
{
public $a;
}
function buildCycle()
{
$a = new A();
$b = new B();
$a->b = $b;
$b->a = $a;
}
function failySoapCall()
{
try {
new SoapClient('https://nowhere.inexistent.space/?WSDL');
}
catch (Exception) {
echo "Soap call failed\n";
}
}
function gc()
{
gc_collect_cycles();
echo "GC Runs: " . gc_status()['runs'] . "\n";
}
buildCycle();
gc();
buildCycle();
gc();
buildCycle();
gc();
failySoapCall();
buildCycle();
gc();
buildCycle();
gc();
buildCycle();
gc();
```
Resulted in this output:
```
GC Runs: 1
GC Runs: 2
GC Runs: 3
Soap call failed
GC Runs: 3
GC Runs: 3
GC Runs: 3
```
But I expected this output instead:
```
GC Runs: 1
GC Runs: 2
GC Runs: 3
Soap call failed
GC Runs: 4
GC Runs: 5
GC Runs: 6
```
The SOAP exception apparently stops the garbage collector. I experienced this problem with a large,
long running process. Its memory usage is intensive but stable. Until it encounters a SOAP
exception: its memory usage skyrockets, and gc_status() reports that no more gc run is done.
### PHP Version
PHP 8.1.13
### Operating System
Alpine 3.16