Skip to content

Fix leak when persistent PDO liveness check fails - #23249

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/pdo-persistent-liveness-leak
Open

Fix leak when persistent PDO liveness check fails#23249
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/pdo-persistent-liveness-leak

Conversation

@iliaal

@iliaal iliaal commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

zend_list_close() only runs PDO's regular resource dtor, which is NULL. A dead cached persistent handle with no other live PDO object was dropped from the cache and never passed to php_pdo_pdbh_dtor. Delete the persistent_list entry so the persistent dtor runs. If another PDO object still holds the handle, the cache entry is only evicted.

zend_list_close() only runs list_dtor_ex, which is NULL for PDO, so a
dead cached handle with refcount 1 was evicted and never freed.
Delete the persistent_list entry so php_pdo_pdbh_dtor runs. Live
handles (refcount > 1) still evict without freeing.
echo $next->query('SELECT 1')->fetchColumn(), "\n";
?>
--EXPECT--
1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how does this test check for the leak?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It triggers the dead-handle reconnect. The leaked handle is pecalloc, so you only see it under valgrind or LSAN, not in --EXPECT--.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Does it depend on some configuration data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants