Bug #73466 --manual-gdb effectively truncates option file args at first semicolon
Submitted: 4 Aug 2014 18:41 Modified: 10 Dec 2014 12:35
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.5+, 5.5.39 OS:Any
Assigned to: CPU Architecture:Any
Tags: gdb, lldb, mtr

[4 Aug 2014 18:41] Laurynas Biveinis
Description:
Invoking an MTR testcase with a --manual-gdb option causes the server not to receive any -master.opt contents past the first semicolon.

How to repeat:
1) Edit mysql_client_test-master.opt so that $PLUGIN options come first:

$PLUGIN_AUTH_OPT
$PLUGIN_AUTH_LOAD
--log=$MYSQLTEST_VARDIR/log/master.log 
--log-output=FILE,TABLE

2) Verify that the edited testcase still works:

main.mysql_client_test                   [ pass ]  36688

3) Now call it with --manual-gdb:

$ ./mysql-test-run mysql_client_test --manual-gdb
...
To start gdb for mysqld.1, type in another window:
gdb -cd /home/laurynas/percona/lp-mysql-server/5.5/mysql-test -x /home/laurynas/percona/lp-mysql-server/5.5/obj-debug/mysql-test/var/tmp/gdbinit.mysqld.1 /home/laurynas/percona/lp-mysql-server/5.5/obj-debug/sql/mysqld

4) Inspect gdbinit.mysqld.1 contents, note the position of semicolon:

$ cat  /home/laurynas/percona/lp-mysql-server/percona-server/5.5/obj-debug/mysql-test/var/tmp/gdbinit.mysqld.1
break main
run --defaults-group-suffix=.1 --defaults-file=/home/laurynas/percona/lp-mysql-server/percona-server/5.5/obj-debug/mysql-test/var/my.cnf --log-output=file --gdb --default-storage-engine=MyISAM --loose-skip-log-bin --plugin-dir=/home/laurynas/percona/lp-mysql-server/percona-server/5.5/obj-debug/plugin/auth --plugin_load=test_plugin_server=auth_test_plugin.so;cleartext_plugin_server=auth_test_plugin.so --utility_user=frank@% --utility_user_password=password --utility_user_schema_access=mysql,performance_schema --utility-user-privileges=CREATE,DROP,SHOW DATABASES --core-file --loose-debug-sync-timeout=300

5) Start mysqld under gdb, check args as shown by gdb:

$ gdb -cd /home/laurynas/percona/lp-mysql-server/5.5/mysql-test -x /home/laurynas/percona/lp-mysql-server/5.5/obj-debug/mysql-test/var/tmp/gdbinit.mysqld.1 /home/laurynas/percona/lp-mysql-server/5.5/obj-debug/sql/mysqld
...
(gdb) show args
Argument list to give program being debugged when it is started is "--defaults-group-suffix=.1 --defaults-file=/home/laurynas/percona/lp-mysql-server/5.5/obj-debug/mysql-test/var/my.cnf --log-output=file --gdb --default-storage-engine=MyISAM --loose-skip-log-bin --plugin-dir=/home/laurynas/percona/lp-mysql-server/5.5/obj-debug/plugin/auth --plugin_load=test_plugin_server=auth_test_plugin.so;cleartext_plugin_server=auth_test_plugin.so --log=/home/laurynas/percona/lp-mysql-server/5.5/obj-debug/mysql-test/var/log/master.log --log-output=FILE,TABLE --core-file --loose-debug-sync-timeout=300".

6) Looks good. Now check argc/argv:

gdb) p argc
$1 = 9
(gdb) p argv[0]
$2 = 0x7fffffffe698 "/home/laurynas/percona/lp-mysql-server/5.5/obj-debug/sql/mysqld"
(gdb) p argv[1]
$3 = 0x7fffffffe6d8 "--defaults-group-suffix=.1"
(gdb) p argv[2]
$4 = 0x7fffffffe6f3 "--defaults-file=/home/laurynas/percona/lp-mysql-server/5.5/obj-debug/mysql-test/var/my.cnf"
(gdb) p argv[3]
$5 = 0x7fffffffe74e "--log-output=file"
(gdb) p argv[4]
$6 = 0x7fffffffe760 "--gdb"
(gdb) p argv[5]
$7 = 0x7fffffffe766 "--default-storage-engine=MyISAM"
(gdb) p argv[6]
$8 = 0x7fffffffe786 "--loose-skip-log-bin"
(gdb) p argv[7]
$9 = 0x7fffffffe79b "--plugin-dir=/home/laurynas/percona/lp-mysql-server/5.5/obj-debug/plugin/auth"
(gdb) p argv[8]
$10 = 0x7fffffffe7e9 "--plugin_load=test_plugin_server=auth_test_plugin.so"
(gdb) p argv[9]
$11 = 0x0

Where is the semicolon and everything past?

7) Watch the testcase fail:
(gdb) c
...
main.mysql_client_test                   [ fail ]
...

Suggested fix:
Don't know
[4 Aug 2014 18:42] Laurynas Biveinis
--manual-lldb as contributed on bug 73418 is affected the same.
[5 Aug 2014 7:04] Umesh Shastry
Hello Laurynas,

Thank you for the bug report and test case.
Verified as described.

Thanks,
Umesh
[5 Aug 2014 7:05] Umesh Shastry
// 5.5.39

[ushastry@ushastry mysql-test]$ more t/mysql_client_test-master.opt 
$PLUGIN_AUTH_OPT
$PLUGIN_AUTH_LOAD
--log=$MYSQLTEST_VARDIR/log/master.log 
--log-output=FILE,TABLE

[ushastry@ushastry mysql-test]$ ./mysql-test-run.pl mysql_client_test
Logging: ./mysql-test-run.pl  mysql_client_test
MySQL Version 5.5.39
Checking supported features...
 - skipping SSL, mysqld not compiled with SSL
 - binaries are debug compiled
Collecting tests...
Removing old var directory...
Creating var directory '/home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var'...
Installing system database...

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
i_main.mysql_client_test                 [ pass ]   4420
main.mysql_client_test                   [ pass ]  36435
--------------------------------------------------------------------------
The servers were restarted 1 times
Spent 40.855 of 53 seconds executing testcases

Completed: All 2 tests were successful.

[ushastry@ushastry mysql-test]$ ./mysql-test-run mysql_client_test --manual-gdb
Logging: ./mysql-test-run  mysql_client_test --manual-gdb
MySQL Version 5.5.39
Checking supported features...
 - skipping SSL, mysqld not compiled with SSL
 - binaries are debug compiled
Collecting tests...
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var'...
Installing system database...

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009

To start gdb for mysqld.1, type in another window:
gdb -cd /home/ushastry/mybuilds/mysql-5.5.39/mysql-test -x /home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var/tmp/gdbinit.mysqld.1 /home/ushastry/mybuilds/mysql-5.5.39/sql/mysqld
i_main.mysql_client_test                 [ fail ]

// Session 2
[ushastry@ushastry mysql-test]$ gdb -cd /home/ushastry/mybuilds/mysql-5.5.39/mysql-test -x /home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var/tmp/gdbinit.mysqld.1 /home/ushastry/mybuilds/mysql-5.5.39/sql/mysqld
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6)
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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ushastry/mybuilds/mysql-5.5.39/sql/mysqld...done.
Breakpoint 1 at 0x555a63: file /home/ushastry/mybuilds/mysql-5.5.39/sql/main.cc, line 25.
[Thread debugging using libthread_db enabled]

Breakpoint 1, main (argc=12, argv=0x7fffffffdfb8) at /home/ushastry/mybuilds/mysql-5.5.39/sql/main.cc:25
25	  return mysqld_main(argc, argv);
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.7.el6.x86_64 libaio-0.3.107-10.el6.x86_64 libgcc-4.4.4-13.el6.x86_64 libstdc++-4.4.4-13.el6.x86_64 nss-softokn-freebl-3.12.9-11.el6.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) show args
Argument list to give program being debugged when it is started is "--defaults-group-suffix=.1 --defaults-file=/home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var/my.cnf --log-output=file --gdb --default-storage-engine=MyISAM --loose-skip-log-bin --general-log=1 --general-log-file=/home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var/log/master.log --log-output=FILE,TABLE --plugin-dir=/home/ushastry/mybuilds/mysql-5.5.39/plugin/auth --plugin_load=test_plugin_server=auth_test_plugin.so;cleartext_plugin_server=auth_test_plugin.so --core-file --loose-debug-sync-timeout=300".
(gdb) p argc
$1 = 12
(gdb) p argv[0]
$2 = 0x7fffffffe301 "/home/ushastry/mybuilds/mysql-5.5.39/sql/mysqld"
(gdb) p argv[1]
$3 = 0x7fffffffe331 "--defaults-group-suffix=.1"
(gdb) p argv[2]
$4 = 0x7fffffffe34c "--defaults-file=/home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var/my.cnf"
(gdb) p argv[3]
$5 = 0x7fffffffe397 "--log-output=file"
(gdb) p argv[4]
$6 = 0x7fffffffe3a9 "--gdb"
(gdb) p argv[5]
$7 = 0x7fffffffe3af "--default-storage-engine=MyISAM"
(gdb) p argv[6]
$8 = 0x7fffffffe3cf "--loose-skip-log-bin"
(gdb) p argv[7]
$9 = 0x7fffffffe3e4 "--general-log=1"
(gdb) p argv[8]
$10 = 0x7fffffffe3f4 "--general-log-file=/home/ushastry/mybuilds/mysql-5.5.39/mysql-test/var/log/master.log"
(gdb) p argv[9]
$11 = 0x7fffffffe44a "--log-output=FILE,TABLE"
(gdb) p argv[10]
$12 = 0x7fffffffe462 "--plugin-dir=/home/ushastry/mybuilds/mysql-5.5.39/plugin/auth"
(gdb) p argv[11]
$13 = 0x7fffffffe4a0 "--plugin_load=test_plugin_server=auth_test_plugin.so"
(gdb) p argv[12]
$14 = 0x0
(gdb) c
Continuing.
..
.
[5 Aug 2014 8:27] Umesh Shastry
// 5.6.20

ushastry@ushastry mysql-test]$ ./mysql-test-run mysql_client_test
Logging: ./mysql-test-run  mysql_client_test
2014-08-05 13:47:41 28239 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)

2014-08-05 13:47:41 28239 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)

2014-08-05 13:47:41 28239 [Note] Plugin 'FEDERATED' is disabled.
2014-08-05 13:47:41 28239 [Note] Binlog end
2014-08-05 13:47:41 28239 [Note] Shutting down plugin 'CSV'
2014-08-05 13:47:41 28239 [Note] Shutting down plugin 'MyISAM'
MySQL Version 5.6.20
Checking supported features...
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
Removing old var directory...
Creating var directory '/home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var'...
Installing system database...

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
main.mysql_client_test                   [ pass ]   7503
i_main.mysql_client_test                 [ pass ]    264
--------------------------------------------------------------------------
The servers were restarted 1 times
Spent 7.767 of 26 seconds executing testcases

Completed: All 2 tests were successful.

[ushastry@ushastry mysql-test]$ ./mysql-test-run mysql_client_test --manual-gdb
Logging: ./mysql-test-run  mysql_client_test --manual-gdb
2014-08-05 13:48:42 28357 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)

2014-08-05 13:48:42 28357 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)

2014-08-05 13:48:42 28357 [Note] Plugin 'FEDERATED' is disabled.
2014-08-05 13:48:42 28357 [Note] Binlog end
2014-08-05 13:48:42 28357 [Note] Shutting down plugin 'CSV'
2014-08-05 13:48:42 28357 [Note] Shutting down plugin 'MyISAM'
MySQL Version 5.6.20
Checking supported features...
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var'...
Installing system database...

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009

To start gdb for mysqld.1, type in another window:
gdb -cd /home/ushastry/mybuilds/mysql-5.6.20/mysql-test -x /home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/tmp/gdbinit.mysqld.1 /home/ushastry/mybuilds/mysql-5.6.20/sql/mysqld
worker[1] mysql-test-run: WARNING: Waited 60 seconds for /home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/mysqld.1/data/auto.cnf to be created, still waiting for 86340 seconds...
worker[1] mysql-test-run: WARNING: Waited 120 seconds for /home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/mysqld.1/data/auto.cnf to be created, still waiting for 86280 seconds...

[ushastry@ushastry mysql-test]$ cat /home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/tmp/gdbinit.mysqld.1
break main
run --defaults-group-suffix=.1 --defaults-file=/home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/my.cnf --log-output=file --gdb --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM --loose-skip-log-bin --plugin-dir=/home/ushastry/mybuilds/mysql-5.6.20/plugin/auth --plugin_load=test_plugin_server=auth_test_plugin.so;cleartext_plugin_server=auth_test_plugin.so --general-log=1 --general-log-file=/home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/log/master.log --log-output=FILE,TABLE --query_cache_type=1 --core-file

[ushastry@ushastry mysql-test]$ gdb -cd /home/ushastry/mybuilds/mysql-5.6.20/mysql-test -x /home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/tmp/gdbinit.mysqld.1 /home/ushastry/mybuilds/mysql-5.6.20/sql/mysqld
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6)
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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ushastry/mybuilds/mysql-5.6.20/sql/mysqld...done.
Breakpoint 1 at 0x6284c3: file /home/ushastry/mybuilds/mysql-5.6.20/sql/main.cc, line 25.
[Thread debugging using libthread_db enabled]

Breakpoint 1, main (argc=11, argv=0x7fffffffdff8) at /home/ushastry/mybuilds/mysql-5.6.20/sql/main.cc:25
25	  return mysqld_main(argc, argv);
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.7.el6.x86_64 libaio-0.3.107-10.el6.x86_64 libgcc-4.4.4-13.el6.x86_64 libstdc++-4.4.4-13.el6.x86_64 nss-softokn-freebl-3.12.9-11.el6.x86_64
(gdb) p argc
$1 = 11
(gdb) p argv[0]
$2 = 0x7fffffffe33c "/home/ushastry/mybuilds/mysql-5.6.20/sql/mysqld"
(gdb) p argv[1]
$3 = 0x7fffffffe36c "--defaults-group-suffix=.1"
(gdb) p argv[2]
$4 = 0x7fffffffe387 "--defaults-file=/home/ushastry/mybuilds/mysql-5.6.20/mysql-test/var/my.cnf"
(gdb) p argv[3]
$5 = 0x7fffffffe3d2 "--log-output=file"
(gdb) p argv[4]
$6 = 0x7fffffffe3e4 "--gdb"
(gdb) p argv[5]
$7 = 0x7fffffffe3ea "--loose-debug-sync-timeout=600"
(gdb) p argv[6]
$8 = 0x7fffffffe409 "--default-storage-engine=MyISAM"
(gdb) p argv[7]
$9 = 0x7fffffffe429 "--default-tmp-storage-engine=MyISAM"
(gdb) p argv[8]
$10 = 0x7fffffffe44d "--loose-skip-log-bin"
(gdb) p argv[9]
$11 = 0x7fffffffe462 "--plugin-dir=/home/ushastry/mybuilds/mysql-5.6.20/plugin/auth"
(gdb) p argv[10]
$12 = 0x7fffffffe4a0 "--plugin_load=test_plugin_server=auth_test_plugin.so"
(gdb) p argv[11]
$13 = 0x0
[3 Sep 2014 15:38] Paul Dubois
Fixed in 5.5.41, 5.6.22, 5.7.6.

Changes for test suite. No changelog entry needed.
[3 Dec 2014 14:25] Laurynas Biveinis
$ bzr log -r 4709
------------------------------------------------------------
revno: 4709
committer: Sayantan Dutta <sayantan.dutta@oracle.com>
branch nick: mysql-5.5
timestamp: Wed 2014-09-03 14:37:00 +0530
message:
  Bug #19361317 - --MANUAL-GDB EFFECTIVELY TRUNCATES OPTION FILE ARGS AT FIRST SEMICOLON
[10 Dec 2014 12:35] Laurynas Biveinis
In 5.6. The first rev carries the diff, the second one is an upmerge.

$ bzr log -r 6145 
------------------------------------------------------------
revno: 6145
committer: Sayantan Dutta <sayantan.dutta@oracle.com>
branch nick: mysql-5.6
timestamp: Wed 2014-09-03 14:40:03 +0530
message:
  upmerge 5.5 => 5.6 19361317

$ bzr log -r 6146
------------------------------------------------------------
revno: 6146 [merge]
committer: Sayantan Dutta <sayantan.dutta@oracle.com>
branch nick: mysql-5.6
timestamp: Wed 2014-09-03 14:57:48 +0530
message:
  upmerge 5.5 => 5.6 19361317