#47928 [Ver->Ctl]: Crash in mysqli_stmt_fetch() with longtext column

From: Date: Sun, 19 Apr 2009 16:19:59 +0000
Subject: #47928 [Ver->Ctl]: Crash in mysqli_stmt_fetch() with longtext column
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135979@lists.php.net to get a copy of this message
ID: 47928 Updated by: jani@php.net Reported By: jjuergens at web dot de -Status: Verified +Status: Critical Bug Type: MySQLi related Operating System: * PHP Version: 5.*, 6CVS (2009-04-19) New Comment: In PHP_5_3 / HEAD the crash happens with any BLOB/TEXT types. (due to mysqli_api.c:398) This might be also a MySQL bug since it seems to set MYSQL_TYPE_BLOB always for any blob column. Previous Comments: ------------------------------------------------------------------------ [2009-04-19 15:14:49] jani@php.net Here's better reproduce data (the longtext column has to have enough data to cause crash): drop database crashtest; create database crashtest; use crashtest; create table crash ( test longtext ); insert into crash set test=' 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 '; grant select on crashtest.* to 'test'@'localhost'; ------------------------------------------------------------------------ [2009-04-19 14:44:29] jjuergens at web dot de Yeah, you're right: Soon as I change the column-type from longtext to text, PHP doesn't crash anymore. The example you provided also crashes on my debug-enabled PHP-Version, while the Opensuse-Version (with Suoshin-Patch) throws efree()-errors until there are more than 396 characters in the textfield. I actually tried to debug the PHP-code some (with very limited knowledge) and I think that the problem is somewhere within the binding of the resultset since thats where the script stops. ------------------------------------------------------------------------ [2009-04-19 14:11:14] jani@php.net See also bug #46808 ------------------------------------------------------------------------ [2009-04-19 14:07:02] jani@php.net Here is the shortest possible test I could come up with: <?php /* Test database and table with data: drop database crashtest; create database crashtest; use crashtest; create table crash ( test longtext ); insert into crash set test='123456789'; grant select on crashtest.* to 'test'@'localhost'; */ $dbLink=new mysqli("localhost","test","","crashtest",3306); $stmt=$dbLink->prepare("SELECT test FROM crash"); $stmt->execute(); $stmt->bind_result($foo); while($stmt->fetch()); $stmt->close(); ?> The problem seems to be with the longtext column. If that is changed to text column, everything works just fine. ------------------------------------------------------------------------ [2009-04-19 10:59:40] jani@php.net Above example causes crash also on my test server. (I removed other irrelevant comments) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/47928 -- Edit this bug report at http://bugs.php.net/?id=47928&edit=1

« previous php.bugs (#135979) next »