[php-src] Issue #11176: Embed SAPI (PHP_EMBED_START_BLOCK/PHP_EMBED_END_BLOCK) memory leak(?)
| From: | jansssson | Date: | Tue, 02 May 2023 10:06:21 +0000 |
| Subject: | [php-src] Issue #11176: Embed SAPI (PHP_EMBED_START_BLOCK/PHP_EMBED_END_BLOCK) memory leak(?) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244328@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11176
Author: jansssson
### Description
I'm assuming it should be possible to run multiple (independent) embedded blocks, one after the
other - I can't find information saying otherwise.
My use case is somewhat advanced, but the repro is really simple.
I cut out code until there was almost nothing left, and basically running multiple
PHP_EMBED_START_BLOCK/PHP_EMBED_END_BLOCK result in an ever increasing memory consumption, which I
guess is a leak of some kind.
In my real use case, at the rate I'm executing embedded blocks, I see a steady linear increase
in RSS of ~200MB/h, with the repro below it's ~1GB/h. Same result in PHP 8.2.4 and PHP 7.4.33.
I've tried various properties/functions of the sapi_module_struct, it doesn't seem to make
a difference, but for reference I have custom callbacks for the following methods:
* php_embed_module.ub_write
* php_embed_module.log_message
* php_embed_module.sapi_error
* zend_error_cb
In essence, the PHP_EMBED_START_BLOCK/PHP_EMBED_END_BLOCK seem to be the culprit.
The following code:
```#include "php_embed.h"
int main()
{
while (1)
{
for(int i = 0; i < 1000; ++i)
{
PHP_EMBED_START_BLOCK(0, NULL)
//zend_eval_string("echo phpinfo();", NULL, "");
PHP_EMBED_END_BLOCK()
}
//Check/print memory consumption
}
}
```
``
./test > /dev/null``
Resulted in this output:
An increase of ~1GB RAM / hour in memory consumption
But I expected this output instead:
A somewhat steady memory consumption
### PHP Version
PHP 8.2.4
### Operating System
_No response_