ID: 49442 Updated by: u...@php.net Reported By: vr...@php.net -Status: Assigned +Status: Closed Bug Type: MySQLi related Operating System: Windows PHP Version: 5.3.0 Assigned To: mysql New Comment:
A patch has been committed to fix the problem. Please try the latest SVN snapshots. The bug affects all operating systems. It is a mysqlnd bug. In theory it should be possible to cause the crash using any MySQL API that uses mysqlnd: ext/mysql, ext/mysqli, PDO_MYSQL. The crash happens both with connections created using mysqli_init() + mysqli_real_connect() and mysqli_connect("p:<host>", ...). Previous Comments: ------------------------------------------------------------------------ [2009-09-16 17:03:45] s...@php.net Automatic comment from SVN on behalf of uw Revision: http://svn.php.net/viewvc/?view=revision&revision=288379 Log: Fix (by Andrey) and test for bug #49442 . Don't use efree() for memory allocated with malloc()... If a connection gets created by mysqli_init(), mysqlnd makes it 'persistent'. 'Persistent' means that mysqlnd uses malloc(). mysqlnd does use malloc() instead of ealloc() because it is unknown if the connection will become a true persistent connection in the sense of ext/mysqli. It is unknown if the user wants a persistent connection or not until the user calls mysqli_real_connect(). To avoid tricky conversions mysqlnd uses malloc(), which sets a private persistent flag in the mysqlnd structures. A precondition for the crash to happen was that the private persistent flag is set. The flag is also set when creating a real persistent connection (in the sense of ext/mysqli) and so the bug can happen with mysql_init()/mysqli_real_connect() and mysql_connect('p:<host>', ...). Therefore we test both cases. Note the (tricky?) difference between the implementation detail'mysqlnd private persistent flag = use malloc()' and persistent connections from a user perspective. Although mysqlnd will always set its private persistent flag and use malloc() for connections created with mysqli_init() it is still up to the user to decide in mysqli_real_connect() if the connection shall become a (true) persistent connection or not. ------------------------------------------------------------------------ [2009-09-02 13:27:42] vr...@php.net CREATE TABLE and sample CSV included in http://www.vrana.cz/phpbug49442.zip ------------------------------------------------------------------------ [2009-09-02 13:21:23] paj...@php.net Please provide the create table and a small CSV to reproduce the problem. ------------------------------------------------------------------------ [2009-09-02 12:46:06] vr...@php.net Backtrace analysis is available at http://www.vrana.cz/phpbug49442.zip ------------------------------------------------------------------------ [2009-09-02 12:32:21] vr...@php.net Description: ------------ LOAD DATA LOCAL INFILE query together with connecting by mysqli_real_connect() causes PHP crash. Maybe it is not the single crashing query but common queries like SELECT or INSERT work. When I replace mysqli_init() + mysqli_real_connect() by mysqli_connect() then everything works (no crash). Reproduce code: --------------- <?php $dbh = mysqli_init(); $dbh->real_connect("", "ODBC", "", "cds"); $dbh->query("LOAD DATA LOCAL INFILE 'songs.csv' INTO TABLE songs"); ?> Expected result: ---------------- Query executed OK. Actual result: -------------- PHP crashes. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49442&edit=1