php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32675 mysql_fetch_field() causes segmentation fault
Submitted: 2005-04-11 17:51 UTC Modified: 2005-04-12 08:54 UTC
From: michael at cosby dot dhs dot org Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.0.4 OS: Linux 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael at cosby dot dhs dot org
New email:
PHP Version: OS:

 

 [2005-04-11 17:51 UTC] michael at cosby dot dhs dot org
Description:
------------
environment:

apache 2.0.52 in multi-threaded mode
mysql 4.1.11 (and 4.1.6-gamma)
PHP 5.0.4

php configuration:
./configure --with-apxs2=/usr/sbin/apxs \
--with-zlib --enable-calendar \
--with-gd --with-mhash \
--with-xsl --enable-memory-limit \
--prefix=/home/php --with-mysql \
--with-openssl --with-jpeg-dir=/usr/lib \
--with-gettext \
--with-curl=/usr/local/lib

Notes:
* This bug does not occur if I use PHP 5.0.2 in the same environment instead of PHP 5.0.4. 

* It's possible that the fix for bug #31288 is related to this issue. This code does *not* call the (deprecated) function mysql_list_fields() at all.


Reproduce code:
---------------
The following code snippet (taken from WordPress wp-includes/wp-db.php, a blogging program):

while ($i < mysql_num_fields($this->result)) {                      
  $this->col_info[$i] = mysql_fetch_field($this->result);         
  $i++;                                                           
}

Even a single invocation of mysql_fetch_field() will cause the  seg. fault. Nothing is written to the server's error log from PHP itself.


Expected result:
----------------
Code inside a script should not cause a seg. fault.


Actual result:
--------------
When using the code snippet specified, the apache child running the request seg. faults.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-11 17:56 UTC] sniper@php.net
Try configure PHP using the external mysql client libraries:
1. delete config.cache file
2 run your configure with this change:
  --with-mysql=/usr (or whatever the install PREFIX is)

Also note: /usr/local/lib or /usr/lib are NOT correct values for any PHP configure option!! They're /usr/local and /usr 

 [2005-04-11 19:54 UTC] georg@php.net
Does the problem still exist if you disable MySQL's query cache?
 [2005-04-11 20:01 UTC] michael at cosby dot dhs dot org
It looks like my query cache is already disabled:

mysql> show variables;
+---------------------------------+----------------------------+
| Variable_name                   | Value                      |
+---------------------------------+----------------------------+
...
| query_cache_limit               | 1048576                    |
| query_cache_min_res_unit        | 4096                       |
| query_cache_size                | 0                          |
| query_cache_type                | ON                         |
| query_cache_wlock_invalidate    | OFF                        |
...


From the mysql manual at http://dev.mysql.com/doc/mysql/en/query-cache.html:

"
To disable the query cache at server startup, set the query_cache_size system variable to 0. By disabling the query cache code, there is no noticeable overhead.
"

(I'm not real familiar with the query cache, so I wanted to be 100% sure it was disabled).
 [2005-04-11 20:04 UTC] michael at cosby dot dhs dot org
For the libraries, it appears that my PHP is *not* compiling with the 4.1.11 client library, but with a 4.0.21 client library. I'm trying to get it to compile with with the 4.1.11 library to see what happens, but I doubt that will fix it since this same 4.0.21 client library works fine with PHP 5.0.2.
 [2005-04-11 22:24 UTC] michael at cosby dot dhs dot org
It appears that I'm already using the external mysql client library, or I'm reading phpinfo() wrong:

MySQL Support	enabled
Active Persistent Links 	0
Active Links 	0
Client API version 	4.0.21
MYSQL_MODULE_TYPE 	external
MYSQL_SOCKET 	/tmp/mysql.sock
MYSQL_INCLUDE 	-I/usr/include/mysql
MYSQL_LIBS 	-L/usr/lib -lmysqlclient
 [2005-04-11 23:13 UTC] sniper@php.net
Noticed this: "apache 2.0.52 in multi-threaded mode"..
What if you try with prefork apache2?



 [2005-04-12 08:43 UTC] michael at cosby dot dhs dot org
Well, that's embarrasing... I was compiling with the mysql 4.1 include files but the 4.0.21 binaries, so of course my pre-compiled 5.0.2 kept working.....
 [2005-04-12 08:54 UTC] tony2001@php.net
No PHP bug -> bogus.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 20:01:34 2025 UTC