You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segfault: Pdo\Mysql::getWarningCount() dereferences the pool template with PDO::ATTR_POOL_ENABLED #201
With PDO::ATTR_POOL_ENABLED, Pdo\Mysql::getWarningCount() segfaults unconditionally. One line of userland PHP is enough.
In pool mode the userland PDO object's pdo_dbh_t is a template whose driver_data is always NULL — real connections live in pool slots. getWarningCount() reads driver_data off Z_PDO_DBH_P(ZEND_THIS) (always the template) and dereferences it.
ext/pdo_mysql/pdo_mysql.c:96-97:
H=dbh->driver_data;
RETURN_LONG(mysql_warning_count(H->server)); /* H == NULL in pool mode */
Crashes even when a slot connection is live (i.e. right after a successful query), because the template is what gets dereferenced, not the slot.
Suggested fix
Route through pdo_pool_peek_conn(dbh) and return 0 when no slot connection is bound to the current context — same shape as the existing lastInsertId / errorInfo handling.
Related
ext/pdo_mysql/pdo_mysql.c:74pdo_mysql_convert_zv_to_mysqlnd (the mysqlnd reverse-API entry point) reads driver_data the same way. Not executed, so unconfirmed, but it looks like the same defect.
Environment
PHP 8.6.0-dev (cli) (ZTS DEBUG TrueAsync ABI v0.24.0)
true_async 0.7.10
pdo_mysql 8.6.0-dev
OS Linux 6.6.114.1-microsoft-standard-WSL2
Found while auditing the pool code path for #200; pre-existing, independent of that fix.
Fixed in php-src true-async-stable, commit 095fd94c5b (changelog PR #209, merged).
Pdo\Mysql::getWarningCount() now reads the slot bound to the current coroutine via pdo_pool_peek_conn() and returns 0 when no slot is held, instead of dereferencing the template's NULLdriver_data. The mysqlnd reverse-API entry point (pdo_mysql_convert_zv_to_mysqlnd) had the same defect and is fixed with it. pdo_pool_peek_conn() became PDO_API since it is now called from a driver.
Regression test: ext/pdo/tests/pdo_pool_022_get_warning_count.phpt — the reproducer exits 139 on the pre-fix binary and 0 after.
Closing as completed; the issue was left open by oversight.
Activity
Merge pull request #209 from true-async/201-203-pdo-pool-changelog
EdmondDantes commentedon Jul 23, 2026
Fixed in php-src
true-async-stable, commit095fd94c5b(changelog PR #209, merged).Pdo\Mysql::getWarningCount()now reads the slot bound to the current coroutine viapdo_pool_peek_conn()and returns0when no slot is held, instead of dereferencing the template'sNULLdriver_data. The mysqlnd reverse-API entry point (pdo_mysql_convert_zv_to_mysqlnd) had the same defect and is fixed with it.pdo_pool_peek_conn()becamePDO_APIsince it is now called from a driver.Regression test:
ext/pdo/tests/pdo_pool_022_get_warning_count.phpt— the reproducer exits 139 on the pre-fix binary and 0 after.Closing as completed; the issue was left open by oversight.
chore(release): 0.8.1