Bug #31173 mysqlslap.exe crashes if called without any parameters

Submitted: 24 Sep 2007 9:33 Modified: 4 Aug 2010 22:32
Reporter: Carsten Segieth Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S1 (Critical)
Version:5.1.22,5.1.45,6.0.3,5.5.0-m2 OS:Windows (XP)
Assigned to: Iggy Galarza CPU Architecture:Any

[24 Sep 2007 9:33] Carsten Segieth
Description:
mysqlslap.exe crashes on Windows if called without any parameters. A message box 

 mysqlslap.exe hat ein Problem festgestellt und muss beendet werden.

appears. This happens e.g. for these command line calls:

 mysqlslap --
 mysqlslap -
 mysqlslap

How to repeat:
see above

Suggested fix:
show help for any not existing / not accepted parameter / combination of parameters.
[16 Nov 2007 14:32] Shane Bester
mysqlslap.exe doesn't run on windows by default.  crashes on startup.  this is because shared_memory_base_name is null and there's no verification before attempting to use it.

stack trace:

mysqlslap.exe!strlen
mysqlslap.exe!create_shared_memory
mysqlslap.exe!mysql_real_connect
mysqlslap.exe!slap_connect
mysqlslap.exe!run_task
mysqlslap.exe!pthread_start
mysqlslap.exe!_callthreadstart
mysqlslap.exe!_threadstart
kernel32.dll!BaseThreadStart
[16 Nov 2007 18:37] Carsten Segieth
From my experience mysqlslap can be used on Windows "in general", but I didn't use all possible --options. I'm using it since some weeks on Win2003 boxes and cannot remember any crash - except in the situation described above.
[27 May 2008 23:52] Venu Anuganti
The fix is to add CLIENT_REMEMBER_OPTIONS to connect_flags in mysqlslap.c. The reason is when the connection is failed (firt time); the options will be erased and sub-sequent connect will crash.

The reason is mysqlslap does retry 10 times for a failed connection; and second time it crashed as first time the options will be cleared.

Here is the patch:
--- mysql-6.0/client/mysqlslap.c        2008-05-27 14:26:16.227646000 -0700
+++ venu/client/mysqlslap.c     2008-05-27 16:51:04.203322000 -0700
@@ -141,7 +141,8 @@
 const char *opt_auto_generate_sql_type= "mixed";

 static unsigned long connect_flags= CLIENT_MULTI_RESULTS |
-                                    CLIENT_MULTI_STATEMENTS;
+                                    CLIENT_MULTI_STATEMENTS |
+                                    CLIENT_REMEMBER_OPTIONS;

 static int verbose, delimiter_length;
 static uint commit_rate;

Here is the stack:

 	mysqlslap.exe!strlen(unsigned char * buf=0x005ba9d4)  Line 81	Asm
>	mysqlslap.exe!create_shared_memory(st_mysql * mysql=0x0012fb4c, st_net * net=0x0012fb4c, unsigned int connect_timeout=0)  Line 490 + 0x15 bytes	C
 	mysqlslap.exe!mysql_real_connect(st_mysql * mysql=0x0012fb4c, const char * host=0x001528c8, const char * user=0x00152886, const char * passwd=0x00702b14, const char * db=0x00000000, unsigned int port=3306, const char * unix_socket=0x00000000, unsigned long client_flag=196608)  Line 1897 + 0x1a bytes	C
 	mysqlslap.exe!slap_connect(st_mysql * mysql=0x0012fb4c, char connect_to_schema=0)  Line 2592 + 0x40 bytes	C
 	mysqlslap.exe!main(int argc=0, char * * argv=0x0015229c)  Line 374 + 0xe bytes	C
 	mysqlslap.exe!__tmainCRTStartup()  Line 327 + 0x19 bytes	C
 	mysqlslap.exe!mainCRTStartup()  Line 196	C
 	kernel32.dll!75a34911() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!76e6e4b6() 	
 	ntdll.dll!76e6e489()
[13 Nov 2008 18:47] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/58690

2728 Ignacio Galarza	2008-11-13
      Bug#31173 - mysqlslap.exe crashes if called without any parameters
      -Applied community patch
      -Cleaned up test
[30 Oct 2009 6:41] Shane Bester
this bug still exists in 5.1.40, whats the holdup here?
[7 Dec 2009 16:16] Andrii Nikitin
Iggy,

Please doublecheck Shane's comment from '16 Nov 2007 15:32'.

For me 5.1.41 mysqlslap.exe crashes if started without -h option. (For some reasons it tries connect using Shared Memory and gets Access violation)

Please make sure that the patch fixes crash when no "-h" option is provided on startup. Or let me know if new bug should be reported.

For me using -h127.0.0.1 option never crashes. 

(please note that all mysql clients use tcp connection to 127.0.0.1 by default: '-h' is not required for that. Probably I will report feature request for using the same behavior for mysqlslap when it doesn't crash anymore).
[24 Dec 2009 6:11] Shane Bester
still crashes in 5.5.0-m2....
[20 Feb 2010 21:10] Shane Bester
still crashes in 5.1.44.......
[17 Mar 2010 9:52] Shane Bester
still crashes 5.1.45 mysqlslap.exe ......
[23 Mar 2010 19:44] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/104120

3141 Ignacio Galarza	2010-03-23
      Bug#31173 - mysqlslap.exe crashes if called without any parameters
      -Applied community patch
      -Cleaned up test
[23 Mar 2010 21:05] Iggy Galarza
Verified the patch works with no -h, -h[HOSTNAME], and -h[Loopback].

D: \> ipconfig /all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : alf

D: \client\relwithdebinfo>mysqlslap.exe -P13000 --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
Benchmark
        Average number of seconds to run all queries: 0.032 seconds
        Minimum number of seconds to run all queries: 0.031 seconds
        Maximum number of seconds to run all queries: 0.047 seconds
        Number of clients running queries: 5
        Average number of queries per client: 0

D: \client\relwithdebinfo>mysqlslap.exe -half -P13000 --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
Benchmark
        Average number of seconds to run all queries: 0.032 seconds
        Minimum number of seconds to run all queries: 0.031 seconds
        Maximum number of seconds to run all queries: 0.047 seconds
        Number of clients running queries: 5
        Average number of queries per client: 0

D: \client\relwithdebinfo>mysqlslap.exe -h127.0.0.1 -P13000 --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
Benchmark
        Average number of seconds to run all queries: 0.027 seconds
        Minimum number of seconds to run all queries: 0.015 seconds
        Maximum number of seconds to run all queries: 0.032 seconds
        Number of clients running queries: 5
        Average number of queries per client: 0
[24 Mar 2010 8:15] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100324081249-yfwol7qtcek6dh7w) (version source revid:alik@sun.com-20100324081113-kc7x1iytnplww91u) (merge vers: 6.0.14-alpha) (pib:16)
[24 Mar 2010 8:18] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100324081159-5b8juv8ldiqwce8v) (version source revid:alik@sun.com-20100324081105-y72rautcea375zxm) (pib:16)
[25 Mar 2010 0:31] Paul DuBois
Noted in 6.0.14 changelog.

On Windows, mysqlslap crashed for attempts to connect via shared
memory. 

Setting report to Need Merge pending push of Celosia to release tree.
[4 Aug 2010 8:07] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:alik@sun.com-20100324081105-y72rautcea375zxm) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 8:23] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:alik@sun.com-20100324081105-y72rautcea375zxm) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 22:32] Paul DuBois
Noted in 5.6.0 changelog.
[22 Dec 2010 5:56] Shane Bester
see bug #59107

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.076 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.