|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-07-06 16:59 UTC] margus at zone dot ee
Description:
------------
mysql_fetch_assoc/mysql_fetch_array will segfault PHP if second parameter (MYSQL_BOTH, MYSQL_ASSOC or MYSQL_NUM) is specified.
The value of parameter does'nt make any difference.
This happens only for PHP-CGI and Apache module and strangely not to CLI.
Reproduce code:
---------------
<?php
mysql_connect ("localhost", "user", "password");
mysql_select_db ("test");
$r = mysql_query ("SELECT * FROM users");
print_r (mysql_fetch_assoc ($r, MYSQL_BOTH));
?>
Expected result:
----------------
Array
(
[id] => 1
[username] => asd1
[email] => asd2
[asd] => 2000
)
Actual result:
--------------
Segmentation fault
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 03:00:02 2025 UTC |
Hello. Actually, Margus was saying that CLI does not crash, that's why he disabled CLI. I tested this case a little further and discovered, that CLI also crashes and this bug appears on x86_64 systems using GCC 3 and with GCC optimization enabled. Using GCC 4 or disabling GCC optimization fixes this bug. These are my results on Debian (squeeze): Configure lines: --------------- CC=gcc-3.4 ./configure --disable-all --with-mysql [DOES NOT WORK] CC=gcc-3.4 CFLAGS=-O1 ./configure --disable-all --with-mysql [DOES NOT WORK] CC=gcc-3.4 CFLAGS=-O0 ./configure --disable-all --with-mysql [WORKS] CC=gcc-4.0 ./configure --disable-all --with-mysql [WORKS] Reproduce code: --------------- sapi/cli/php -r "mysql_fetch_array (fopen ('php://stdin', 'r'), MYSQL_BOTH);" (I'm using fopen, because the first parameter must be some kind of resource, but the actual value makes no difference) Expected result: ---------------- Warning: mysql_fetch_array(): supplied resource is not a valid MySQL result resource in Command line code on line 1 Actual result: -------------- Segmentation fault