Bug #3181 insert_test client test missing mysql_init
Submitted: 15 Mar 2004 13:40 Modified: 31 Mar 2004 0:30
Reporter: Kurt Granroth Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.18/4.0.19 OS:
Assigned to: Sergei Glukhov CPU Architecture:Any

[15 Mar 2004 13:40] Kurt Granroth
Description:
The insert_test client test program in mysql-4.0.18/client seg faults when 
mysql_real_connect() is called.  This is due to that function's need to have 
mysql_init() called before it.  The mysql_init() function is not called in 
insert_test.c and therefore the program crashes. 

How to repeat:
1) Compile insert_test 
2) Run insert_test 
 
>gdb ./insert_test 
GNU gdb 5.3 
Copyright 2002 Free Software Foundation, Inc. 
 
(gdb) r test 1 
Starting program: /home/tmp/mysql-4.0.18/client/insert_test test 1 
 
Program received signal SIGSEGV, Segmentation fault. 
0x400e0cb4 in free () from /lib/libc.so.6 
(gdb) where 
#0  0x400e0cb4 in free () from /lib/libc.so.6 
#1  0x4003f026 in my_no_flags_free () from /usr/lib/libmysqlclient.so.12 
#2  0x4003aed9 in mysql_real_connect () from /usr/lib/libmysqlclient.so.12 
#3  0x080486ec in main () 
#4  0x40085d8c in __libc_start_main () from /lib/libc.so.6 
 

Suggested fix:
--- insert_test.c.orig  2004-03-15 14:40:22.000000000 -0700 
+++ insert_test.c       2004-03-15 14:39:58.000000000 -0700 
@@ -33,6 +33,7 @@ 
     exit(1); 
   } 
 
+  mysql_init(&mysql); 
   if (!(sock = mysql_real_connect(&mysql,NULL,NULL,NULL,argv[1],0,NULL,0))) 
   { 
     fprintf(stderr,"Couldn't connect to engine!\n%s\n",mysql_error(&mysql));
[16 Mar 2004 15:31] MySQL Verification Team
Verified on 4.0.19. Thank you for your bug report.
[31 Mar 2004 0:30] Sergei Glukhov
Fixed in source tree