-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLite3 callback functions cause a memory leak with a callable array #11878
Comments
Hmm. Applying GH-11850 does not solve the issue. |
I managed to build a reproducer that reproduces the underlying issue on 8.1 and higher. <?php
class Foo {
public $sqlite;
public function __construct() {
$this->sqlite = new SQLite3(":memory:");
$this->sqlite->createAggregate("indexes", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 9);
}
public function SQLiteIndex() {}
public function SQLiteFinal() {}
}
$x = new Foo; |
|
…a callable array In this test file, the free_obj handler is called with a refcount of 2, caused by the fact it participates in a cycle and we do a GC_ADDREF() to increase its refcount. We never decrease its refcount so it never becomes 0 causing a memory leak. This happens in shutdown. Whether it is actually useful to check the refcount afterwards is up for debate.
…a callable array In this test file, the free_obj handler is called with a refcount of 2, caused by the fact we do a GC_ADDREF() to increase its refcount while its refcount is still 1 because the Foo object hasn't been destroyed yet (due to the cycle caused by the sqlite function callback). Solve this by introducing a get_gc handler. Closes phpGH-11881.
…a callable array In this test file, the free_obj handler is called with a refcount of 2, caused by the fact we do a GC_ADDREF() to increase its refcount while its refcount is still 1 because the Foo object hasn't been destroyed yet (due to the cycle caused by the sqlite function callback). Solve this by introducing a get_gc handler. Closes phpGH-11881.
* PHP-8.1: Fix GH-11878: SQLite3 callback functions cause a memory leak with a callable array
* PHP-8.2: Fix GH-11878: SQLite3 callback functions cause a memory leak with a callable array
* PHP-8.3: Fix GH-11878: SQLite3 callback functions cause a memory leak with a callable array
Description
I'm trying phpdoc on http://doc.php.net/tutorial/local-setup.php, then displays memory leak. (My PHP environment is include
--enable-debug
)The following code:
Resulted in this output:
But I expected this output instead:
I expected displays nothing about memory leak.
PHP Version
PHP 8.3.0 (master)
Operating System
macOS 13.4.1
The text was updated successfully, but these errors were encountered: