ID:               16272
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         MySQL related
 Operating System: Linux 2.4.x
 PHP Version:      4.1.2
 New Comment:

I was affected by the same bug, but I've found a workaround.
On linux 2.4.18, glibc 2.2.3 and MySQL 3.23.49, apache 1.3.24 with php
4.1.2 statically compiled (mysql external driver,
--with-mysql=mysql_install_dir)

by explicitly indicating the link id, mysql seems to work fine. So

$conn = mysql_pconnect("host","username","pass");
mysql_select_db("db1");
$query = mysql_query("SELECT * FROM xxx")
while ($row = mysql_fetch_array($query)) do_stuff();

would randomly segfault apache, while

$conn = mysql_pconnect("host","username","pass");
mysql_select_db("db1",$conn);
$query = mysql_query("SELECT * FROM xxx",$conn)
while ($row = mysql_fetch_array($query)) do_stuff();

works without problem.


Previous Comments:
------------------------------------------------------------------------

[2002-04-03 14:24:47] [EMAIL PROTECTED]

I just set up a separate box to test if this bug has anything to do
with what version of glibc is used.

The bug is still there in the following setup:

glibc-2.2.4-19.3 (RedHat Linux 7.2)
MySQL-3.23.42-1
PHP v4.1.2 compiled as a static module for Apache 1.3.22

------------------------------------------------------------------------

[2002-03-26 13:42:23] [EMAIL PROTECTED]

The bug still shows up in 4.2.0RC1

------------------------------------------------------------------------

[2002-03-26 13:41:16] [EMAIL PROTECTED]

The segfault occurs in the following code snippet (a db wrapper that we
wrote for MySQL). What is odd is that this only happens on occasion:
this method is called exceptionally often in our code and only breaks
(in 4.1.x, not 4.0.x) once in a while and not on exceptional
queries--we have, for instance, seen it break on a query that returns
only one row. Anyway, here's the code:

        /** 
        * send a query to the DBMS using the dbLinkID
        * @param $dbLink - the link connection ID [INT]
        * @param $query [STRING]
        * @return the query in ORACLE format $result[FIELDNAME][ROWNUM]=value
[2D HASH]
        * @access public
        */
        function db_query($dbLink, $query){
                $res=mysql_db_query($this->dbase,$query,$dbLink);
                while($row=@mysql_fetch_array($res,MYSQL_ASSOC)){
                        while(list($key,$val)=@each($row)){
                                $result[$key][]=$val;
                        }
                        $x++;
                }
                if(!is_array($result)) $result=array(); 
                return $result;
        }

Thanks for looking into this.

--jonathan

------------------------------------------------------------------------

[2002-03-26 07:59:40] [EMAIL PROTECTED]

When does this segfault occur? Can you provide a sample script?
Also, can you try 4.2.0RC1 (see www.php.net/~derick) and see if it has
been fixed?

------------------------------------------------------------------------

[2002-03-25 19:48:58] [EMAIL PROTECTED]

maybe related to BUG #14860; here's the backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x813a1e5 in zend_fetch_resource (passed_id=0x829ca50, default_id=-1,
    resource_type_name=0x819174e "MySQL-Link", found_resource_type=0x0,
num_resource_types=2)
    at zend_list.c:123
123                     } else if ((*passed_id)->type != IS_RESOURCE)
{
(gdb) bt
#0  0x813a1e5 in zend_fetch_resource (passed_id=0x829ca50,
default_id=-1,
    resource_type_name=0x819174e "MySQL-Link", found_resource_type=0x0,
num_resource_types=2)
    at zend_list.c:123
#1  0x809363c in php_mysql_do_query_general (query=0x829ca4c,
mysql_link=0x829ca50,
    link_id=-1, db=0x829ca48, use_store=1, return_value=0x8633cf4) at
php_mysql.c:981
#2  0x8093bc2 in zif_mysql_db_query (ht=3, return_value=0x8633cf4,
this_ptr=0x0,
    return_value_used=1) at php_mysql.c:1113
#3  0x8156da1 in execute (op_array=0x8622a44) at ./zend_execute.c:1590
#4  0x8156f79 in execute (op_array=0x844e7bc) at ./zend_execute.c:1630
#5  0x8156f79 in execute (op_array=0x859930c) at ./zend_execute.c:1630
#6  0x8156f79 in execute (op_array=0x86092a8) at ./zend_execute.c:1630
#7  0x8156f79 in execute (op_array=0x8530668) at ./zend_execute.c:1630
#8  0x8156f79 in execute (op_array=0x8617eec) at ./zend_execute.c:1630
#9  0x8158c96 in execute (op_array=0x82c8a8c) at ./zend_execute.c:2133
#10 0x813395c in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at zend.c:814
#11 0x8080dee in php_execute_script (primary_file=0xbffff938) at
main.c:1307
#12 0x813e8f9 in apache_php_module_main (r=0x82344ac,
display_source_mode=0)
    at sapi_apache.c:90
#13 0x807d876 in send_php ()
#14 0x807d8cf in send_parsed_php ()
#15 0x8160d93 in ap_invoke_handler ()
#16 0x8174d19 in process_request_internal ()
#17 0x8174d7c in ap_process_request ()
#18 0x816c30e in child_main ()
#19 0x816c4a0 in make_child ()
#20 0x816c5f9 in startup_children ()
#21 0x816cc56 in standalone_main ()
#22 0x816d413 in main ()
#23 0x40140e29 in __libc_start_main () from /lib/libc.so.6

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=16272&edit=1

Reply via email to