[tpcc-mysql] SIGABRT on load.c:277

Bug #692544 reported by Daniël van Eeden
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
percona-tools
New
Undecided
Unassigned

Bug Description

Error(0) is called in load.c:277 as the connection failed.

mysql_real_connect was called on line 177 or 180 and the response stored in resp. The goto on line 188 triggered the call to Error(0).

The Error function is defined on line 1216 and does a mysql_close(mysql)

The patch will do a goto Error_SqlCall instead of Error_SqlCall_close if the mysql_errno is 2003.

user@host:~/dev/tpcc-mysql$ gdb --args ./tpcc_load localhost tpcc user pass 1
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/user/dev/tpcc-mysql/tpcc_load...done.
(gdb) r
Starting program: /home/user/dev/tpcc-mysql/tpcc_load localhost tpcc user pass 1
[Thread debugging using libthread_db enabled]
*************************************
*** ###easy### TPC-C Data Loader ***
*************************************
<Parameters>
     [server]: localhost
     [port]: 3306
     [DBname]: tpcc
       [user]: user
       [pass]: pass
  [warehouse]: 1
[New Thread 0xb7fe4b70 (LWP 8240)]

2002, HY000, Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
*** glibc detected *** /home/user/dev/tpcc-mysql/tpcc_load: double free or corruption (top): 0x08052dd8 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0x417591]
/lib/tls/i686/cmov/libc.so.6(+0x6cde8)[0x418de8]
/lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0x41becd]
/usr/lib/libmysqlclient_r.so.16(my_no_flags_free+0x21)[0x172531]
/usr/lib/libmysqlclient_r.so.16(mysql_close+0x163)[0x1a2ca3]
/home/user/dev/tpcc-mysql/tpcc_load(Error+0xb7)[0x80496e7]
/home/user/dev/tpcc-mysql/tpcc_load(main+0x44e)[0x804bcfe]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x3c2bd6]
/home/user/dev/tpcc-mysql/tpcc_load[0x8049591]
======= Memory map: ========
00110000-0012b000 r-xp 00000000 08:01 3801123 /lib/ld-2.11.1.so
0012b000-0012c000 r--p 0001a000 08:01 3801123 /lib/ld-2.11.1.so
0012c000-0012d000 rw-p 0001b000 08:01 3801123 /lib/ld-2.11.1.so
0012d000-0012e000 r-xp 00000000 00:00 0 [vdso]
0012e000-002da000 r-xp 00000000 08:01 664296 /usr/lib/libmysqlclient_r.so.16.0.0
002da000-002db000 ---p 001ac000 08:01 664296 /usr/lib/libmysqlclient_r.so.16.0.0
002db000-002de000 r--p 001ac000 08:01 664296 /usr/lib/libmysqlclient_r.so.16.0.0
002de000-00323000 rw-p 001af000 08:01 664296 /usr/lib/libmysqlclient_r.so.16.0.0
00323000-00324000 rw-p 00000000 00:00 0
00324000-00339000 r-xp 00000000 08:01 3805714 /lib/tls/i686/cmov/libpthread-2.11.1.so
00339000-0033a000 r--p 00014000 08:01 3805714 /lib/tls/i686/cmov/libpthread-2.11.1.so
0033a000-0033b000 rw-p 00015000 08:01 3805714 /lib/tls/i686/cmov/libpthread-2.11.1.so
0033b000-0033d000 rw-p 00000000 00:00 0
0033d000-00346000 r-xp 00000000 08:01 3805701 /lib/tls/i686/cmov/libcrypt-2.11.1.so
00346000-00347000 r--p 00008000 08:01 3805701 /lib/tls/i686/cmov/libcrypt-2.11.1.so
00347000-00348000 rw-p 00009000 08:01 3805701 /lib/tls/i686/cmov/libcrypt-2.11.1.so
00348000-0036f000 rw-p 00000000 00:00 0
0036f000-00382000 r-xp 00000000 08:01 3805706 /lib/tls/i686/cmov/libnsl-2.11.1.so
00382000-00383000 r--p 00012000 08:01 3805706 /lib/tls/i686/cmov/libnsl-2.11.1.so
00383000-00384000 rw-p 00013000 08:01 3805706 /lib/tls/i686/cmov/libnsl-2.11.1.so
00384000-00386000 rw-p 00000000 00:00 0
00386000-003aa000 r-xp 00000000 08:01 3805704 /lib/tls/i686/cmov/libm-2.11.1.so
003aa000-003ab000 r--p 00023000 08:01 3805704 /lib/tls/i686/cmov/libm-2.11.1.so
003ab000-003ac000 rw-p 00024000 08:01 3805704 /lib/tls/i686/cmov/libm-2.11.1.so
003ac000-004ff000 r-xp 00000000 08:01 3805699 /lib/tls/i686/cmov/libc-2.11.1.so
004ff000-00500000 ---p 00153000 08:01 3805699 /lib/tls/i686/cmov/libc-2.11.1.so
00500000-00502000 r--p 00153000 08:01 3805699 /lib/tls/i686/cmov/libc-2.11.1.so
00502000-00503000 rw-p 00155000 08:01 3805699 /lib/tls/i686/cmov/libc-2.11.1.so
00503000-00506000 rw-p 00000000 00:00 0
00506000-00519000 r-xp 00000000 08:01 3801098 /lib/libz.so.1.2.3.3
00519000-0051a000 r--p 00012000 08:01 3801098 /lib/libz.so.1.2.3.3
0051a000-0051b000 rw-p 00013000 08:01 3801098 /lib/libz.so.1.2.3.3
0051b000-00538000 r-xp 00000000 08:01 3801102 /lib/libgcc_s.so.1
00538000-00539000 r--p 0001c000 08:01 3801102 /lib/libgcc_s.so.1
00539000-0053a000 rw-p 0001d000 08:01 3801102 /lib/libgcc_s.so.1
08048000-0804d000 r-xp 00000000 00:17 24631559 /home/user/dev/tpcc-mysql/tpcc_load
0804d000-0804e000 r--p 00005000 00:17 24631559 /home/user/dev/tpcc-mysql/tpcc_load
0804e000-0804f000 rw-p 00006000 00:17 24631559 /home/user/dev/tpcc-mysql/tpcc_load
0804f000-08073000 rw-p 00000000 00:00 0 [heap]
b7600000-b7621000 rw-p 00000000 00:00 0
b7621000-b7700000 ---p 00000000 00:00 0
b77af000-b77e4000 r--s 00000000 08:01 262319 /var/cache/nscd/services
b77e4000-b77e5000 ---p 00000000 00:00 0
b77e5000-b7fe8000 rw-p 00000000 00:00 0
b7ffd000-b8000000 rw-p 00000000 00:00 0
bffeb000-c0000000 rw-p 00000000 00:00 0 [stack]
[Thread 0xb7fe4b70 (LWP 8240) exited]

Program received signal SIGABRT, Aborted.
0x0012d422 in __kernel_vsyscall ()
(gdb) bt f
#0 0x0012d422 in __kernel_vsyscall ()
No symbol table info available.
#1 0x003d6651 in raise () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#2 0x003d9a82 in abort () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#3 0x0040d49d in ?? () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#4 0x00417591 in ?? () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#5 0x00418de8 in ?? () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#6 0x0041becd in free () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#7 0x00172531 in my_no_flags_free () from /usr/lib/libmysqlclient_r.so.16
No symbol table info available.
#8 0x001a2ca3 in mysql_close () from /usr/lib/libmysqlclient_r.so.16
No symbol table info available.
#9 0x080496e7 in Error (mysql_stmt=0x0) at load.c:1231
No locals.
#10 0x0804bcfe in main (argc=6, argv=0xbffff8d4) at load.c:277
        connect_string = "localhost\000\000\364\337\004\b\370\367\377\277\250\222\004\b0\340\021\000\364\337\004\b(\370\377\277i\306\004\b$#P\000\364\037P\000P\306\004\b"
        db_string = "tpcc\000\b8\370\377\277T\312\022\000\000\000\000\000\260~\376\267\001\000\000\000\000\000\000\000\001\000\000\000\370\310\022\000\300\330-\000\024\270-\000\245\262=\000\b"
        db_user = "user\000\260~\376\267\060x\376\267\005\216\004\b\260\216;\000\220\206\004\b\001\000\000\000\364\277\022\000\200\370\377\277\260\312\022\000T\370\377\277R\222\021\000D", <incomplete sequence \370>
        db_password = "pass\000\367\377\277\277\000\000\000\016\000\000\000\220\206;\000\200~\376\267.N=\366\000\000\000\000\t\000\000\000\370\310\022\000\000\000\000\000\000\000\000\000\001\000"
        port = 3306
        i = -1073743660
        resp = <value optimised out>
(gdb) q
A debugging session is active.

 Inferior 1 [process 8237] will be killed.

Quit anyway? (y or n) y
user@host:~/dev/tpcc-mysql$

Tags: patch
Revision history for this message
Daniël van Eeden (dveeden) wrote :
Revision history for this message
Daniël van Eeden (dveeden) wrote :

The patch is not complete. Not only mysql_errno 2003 can happen but also 2002...

Revision history for this message
Liang Xie (xieliang007) wrote :

Yes , i hit 2002, HY000

Revision history for this message
Liang Xie (xieliang007) wrote :

Per Daniël van Eeden, i modified as following and looks OK to me now:

diff src/load.c ~/load.c
188,192c188
< if(mysql_errno(mysql) == 2003 || mysql_errno(mysql) == 2002){
< goto Error_SqlCall;
< }else{
< goto Error_SqlCall_close;
< }
---
> goto Error_SqlCall_close;

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.