Bug #20858 Mysql client application crashes while calling mysql_real_query
Submitted: 5 Jul 2006 4:39 Modified: 5 Aug 2006 12:43
Reporter: Renuka R Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.20 OS:Soalris
Assigned to: Assigned Account CPU Architecture:Any

[5 Jul 2006 4:39] Renuka R
Mysql client application crashes while calling mysql_real_query

How to repeat:
1. Compile the Mysql-4.1.20 source code. with the procedure

shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &

2. Compile Mysql client application(It should have a call for mysql_real_query) with the binaries obtained by compiling Mysql-4.1.20 source code.

3. Run the Mysql Client application. 

     But Mysql Client application crashes as soon as mysql_real_query is encountered

The back trace is as below where oam_lipam_db_act_as_slave is the MySQL client application function.

(gdb) bt
#0  0xfe89fb84 in _lwp_kill () from /usr/lib/libc.so.1
#1  0xfe850ba4 in raise () from /usr/lib/libc.so.1
#2  0xff165bb4 in __sighndlr () from /usr/lib/libthread.so.1
#3  0xff15f80c in call_user_handler () from /usr/lib/libthread.so.1
#4  <signal handler called>
#5  0xfe740bac in cli_advanced_command ()
   from /usr/local/mysql/lib/mysql//libmysqlclient.so.14
#6  0xfe73f95c in mysql_send_query ()
   from /usr/local/mysql/lib/mysql//libmysqlclient.so.14
#7  0xfe73f9d4 in mysql_real_query ()
   from /usr/local/mysql/lib/mysql//libmysqlclient.so.14
#8  0xfea0ba98 in oam_lipam_db_act_as_slave (p_mysql_recv=0x7a445c, 
      {count = 0 '\0', data = "OAM_LIData", '\0' <repeats 117 times>}, 
      {count = 0 '\0', data = "OAM_LIData", '\0' <repeats 117 times>}, 
      {count = 0 '\0', data = "/usr/local/mysql_compiled_pkg", '\0' <repeats 98 times>}, slave_path=
      {count = 0 '\0', data = "/usr/local/mysql_compiled_pkg", '\0' <repeats 98 times>}, master_port=32478, slave_port=32478, master_socket=
      {count = 0 '\0', data = "/tmp/oam_renu_comp.sock", '\0' <repeats 104 times>}, slave_socket=
---Type <return> to continue, or q <return> to quit---
      {count = 0 '\0', data = "/tmp/oam_renu_comp.sock", '\0' <repeats 104 times>}, host={count = 0 '\0', data = "", '\0' <repeats 113 times>}, 
    user={count = 0 '\0', data = "oam", '\0' <repeats 124 times>}, pswd=
      {count = 0 '\0', data = "oam", '\0' <repeats 124 times>}, 
    at /cm_data/gateway_product/mgc/oam_manager/lipam/db_client/src/oam_lipam_db_client_util.c:246

I checked it with the MySQL 4.1.20 binary package downloaded from website with with MYSQL Client apllication had no problem with the compilw mysql , client program crashes.

Also if you are require the mysql source code and binaries , i shall be able to provide that. But please explain me as how can i send it to you.
As i found no attachment section here.

Please help for the fixing this problem.

[5 Jul 2006 8:51] Sveta Smirnova
I can't crash my application with mysql_real_query using mysql-4.1.21 libraries compiled with Sun Studio. Could you please provide code which can do it?

To attach files click "Files" tab above bug description.
[5 Jul 2006 9:19] Renuka R
my client program is

#include <stdlib.h>
#include "/usr/local/mysql/include/mysql/mysql.h"
#include <stdio.h>

int main(){
   MYSQL *mysql, obj_mysql;
   MYSQL_RES *res;
   MYSQL_ROW row;
   char *query,*fip;
   int t,r;

void                            **p_p_mysql_recv;
p_p_mysql_recv = (void**)malloc(sizeof(char*));
mysql = (MYSQL *)*p_p_mysql_recv;

*p_p_mysql_recv = NULL;

*p_p_mysql_recv = (void*)malloc(sizeof(MYSQL));

//mysql = &obj_mysql;

//if( NULL ==  mysql_init(mysql))
if (NULL == mysql_init((MYSQL *)*p_p_mysql_recv))
 printf("mysql pointer is null \n ");
 printf("mysql pointer is NOT null \n ");

//if (!mysql_real_connect(mysql,"","oam","oam","OAM_LIData",32478,"/tmp/oam_renu_comp.sock",0))
if (!mysql_real_connect((MYSQL *)*p_p_mysql_recv,"","oam","oam","OAM_LIData",32478,"/tmp/oam_renu_comp.sock",0))
fprintf(stderr, "Failed to connect to database: Error: %s\n",
mysql_error((MYSQL *)*p_p_mysql_recv));
   else printf("Connected...\n");

query="select * from OAM_DF_INFO";

   //t=mysql_real_query(mysql,query,(unsigned int) strlen(query));
   t=mysql_real_query((MYSQL *)*p_p_mysql_recv,query,(unsigned int) strlen(query));
   if (t)
      printf("Error making query: %s\n",
              mysql_error((MYSQL *)*p_p_mysql_recv));
   else printf("Query made...\n");

res=mysql_use_result((MYSQL *)*p_p_mysql_recv);
/*   for(r=0;r<=mysql_field_count(mysql);r++){
           if(!row) break;
                   if(row[t]) printf("%s ",row[t]);
  //printf("The existing sock fd is %d\n",mysql->NET.fd);
printf("Existing fip is %s\n",fip);


//printf("The CGHANGED sock fd is %d\n",mysql->NET.fd);

 mysql_close((MYSQL *)*p_p_mysql_recv);
[5 Jul 2006 12:43] Sveta Smirnova
I still can not repeat crash using your code and last sources.

Which compiler do you use? What version of Solaris do you use?
[5 Aug 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".