From:             artem at osp dot ru
Operating system: Linux 2.2.25
PHP version:      4.3.2
PHP Bug Type:     MySQL related
Bug description:  Segmentation fault after second mysql_connect

Description:
------------
I need two connections to mysql server for processing big result trought
mysql_unbuffered_query(). 
But on mysql_fetch_row() after second connect there is error.

php was configured:

./configure  --with-mysql=/opt/mysql --enable-track-vars --with-gd
--with-zlib-dir=/usr/lib/ --enable-memory-limit --enable-debug
--with-apache=../apache_1.3.27-ssl

mysql version 4.0.13
mysql was configured:

./configure '--prefix=/opt/mysql-4.0.13'
'--with-mysqld-ldflags=-all-static' '--disable-shared'
'--with-charset=cp1251' '--with-innodb' '--enable-local-inf
ile'


Reproduce code:
---------------
<?php
 function my_connect() {
  [EMAIL PROTECTED]("localhost","<login>","<pass>",1);
  if(!$s) {
   echo "Troubes at connect to MySQL. ".mysql_error();
   exit;
  }
  if(!mysql_select_db("<DB>")) {
   echo "Troubes at select DB on MySQL. ".mysql_error();
   exit;
  }
  return $s;
 }
 ob_implicit_flush(1);
 echo "1<br>\n";
 my_connect();
 echo "2<br>\n";
 $res=mysql_unbuffered_query("select 'All ok'");
 echo "3<br>\n";
 if(!$res) {
  echo "Mysql say: ".mysql_error();
  exit;
 }
 my_connect();
 echo "4<br>\n";
 $row=mysql_fetch_row($res);
 echo "5<br>\n";
 echo $row[0];
?>


Expected result:
----------------
1
2
3
4
5
All ok

Actual result:
--------------
1
2
3
4

==========================
Segmentation fault
==========================
[www2:/opt/www/bin]:1087# gdb /opt/www/bin/httpd
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux"...
(gdb) run -X
Starting program: /opt/www/bin/httpd -X

Program received signal SIGSEGV, Segmentation fault.
0x822263d in my_net_read ()
(gdb) bt
#0  0x822263d in my_net_read ()
#1  0x8217a1b in net_safe_read ()
#2  0x82185c8 in read_one_row ()
#3  0x821b92b in mysql_fetch_row ()
#4  0x80f667b in php_mysql_fetch_hash (ht=1, return_value=0x840ba7c,
    this_ptr=0x0, return_value_used=1, result_type=2, expected_args=1)
    at /usr/local/src/php-4.3.2-ssl/ext/mysql/php_mysql.c:1886
#5  0x80f689a in zif_mysql_fetch_row (ht=1, return_value=0x840ba7c,
    this_ptr=0x0, return_value_used=1)
    at /usr/local/src/php-4.3.2-ssl/ext/mysql/php_mysql.c:1937
#6  0x80b1adf in execute_internal (execute_data_ptr=0xbfffcca0,
    return_value_used=1)
    at /usr/local/src/php-4.3.2-ssl/Zend/zend_execute_API.c:42
#7  0x3452e2 in xdebug_execute_internal (current_execute_data=0xbfffcca0,
    return_value_used=1) at /tmp/tmprX1YIP/xdebug-1.2.0/xdebug.c:782
#8  0x80cbed1 in execute (op_array=0x840ac5c)
    at /usr/local/src/php-4.3.2-ssl/Zend/zend_execute.c:1608
#9  0x3451f6 in xdebug_execute (op_array=0x840ac5c)
    at /tmp/tmprX1YIP/xdebug-1.2.0/xdebug.c:750
#10 0x80bc28e in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /usr/local/src/php-4.3.2-ssl/Zend/zend.c:869
#11 0x8092554 in php_execute_script (primary_file=0xbffff3b0)
    at /usr/local/src/php-4.3.2-ssl/main/main.c:1671
---Type <return> to continue, or q <return> to quit---
#12 0x80d0882 in apache_php_module_main (r=0x83f2f7c,
display_source_mode=0)
    at /usr/local/src/php-4.3.2-ssl/sapi/apache/sapi_apache.c:54
#13 0x8088df0 in send_php ()
#14 0x8088e49 in send_parsed_php ()
#15 0x81d9fb7 in ap_invoke_handler ()
#16 0x81ef52b in process_request_internal ()
#17 0x81ef58c in ap_process_request ()
#18 0x81e620d in child_main ()
#19 0x81e63dc in make_child ()
#20 0x81e6550 in startup_children ()
#21 0x81e6bc8 in standalone_main ()
#22 0x81e7447 in main ()
#23 0x1eff31 in __libc_start_main (main=0x81e7084 <main>, argc=2,
    ubp_av=0xbffff7f4, init=0x808515c <_init>, fini=0x828de10 <_fini>,
    rtld_fini=0x11e274 <_dl_fini>, stack_end=0xbffff7ec)
    at ../sysdeps/generic/libc-start.c:129
(gdb)

-- 
Edit bug report at http://bugs.php.net/?id=24535&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24535&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24535&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24535&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24535&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24535&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24535&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24535&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24535&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24535&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24535&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24535&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24535&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24535&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24535&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24535&r=gnused

Reply via email to