Bug #86049 Client testcases failing with --valgrind-clients in getaddrinfo
Submitted: 23 Apr 2017 19:09 Modified: 14 Aug 2017 10:26
Reporter: Laurynas Biveinis Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:8.0.1, 8.0.2 OS:Linux (Ubuntu 17.04)
Assigned to: CPU Architecture:Any
Tags: valgrind

[23 Apr 2017 19:09] Laurynas Biveinis
Description:
cmake ... -DWITH_DEBUG=ON -DWITH_VALGRIND=ON
...
$ ./mtr --debug-server --valgrind-clients mysql
...
main.mysql                               [ fail ]
        Test ended at 2017-04-23 22:01:04

CURRENT_TEST: main.mysql
mysqltest: At line 221: command "$MYSQL test -e "\r test invalid_hostname" 2>&1" failed with wrong error: 42
...

If the trailing "2>&1" is removed from line 221, then the error itself is shown:

main.mysql                               [ fail ]
        Test ended at 2017-04-23 22:03:57

CURRENT_TEST: main.mysql
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'invalid_hostname' (11)
==2459== 4,096 bytes in 1 blocks are definitely lost in loss record 4 of 4
==2459==    at 0x4C2DB2F: malloc (vg_replace_malloc.c:299)
==2459==    by 0x4045991: ???
==2459==    by 0x40438DB: ???
==2459==    by 0x4068060: ???
==2459==    by 0x4044DDC: ???
==2459==    by 0x66CF16E: gaih_inet.constprop.5 (getaddrinfo.c:848)
==2459==    by 0x66D1447: getaddrinfo (getaddrinfo.c:2391)
==2459==    by 0x1823DE: mysql_real_connect (client.cc:4518)
==2459==    by 0x170C62: sql_real_connect(char*, char*, char*, char*, unsigned int) (mysql.cc:4956)
==2459==    by 0x1710A2: sql_connect(char*, char*, char*, char*, unsigned int) (mysql.cc:5095)
==2459==    by 0x16FE61: com_connect(String*, char*) (mysql.cc:4569)
==2459==    by 0x16A4E5: add_line(String&, char*, unsigned long, char*, bool*, bool) (mysql.cc:2570)
==2459==    by 0x169AD0: read_and_execute(bool) (mysql.cc:2344)
==2459==    by 0x168674: main (mysql.cc:1466)
==2459== 
mysqltest: At line 221: command "$MYSQL test -e "\r test invalid_hostname"" failed with wrong error: 42

How to repeat:
See above
[24 Apr 2017 5:39] MySQL Verification Team
Hello Laurynas,

Thank you for the report.
On OL7, built with cmake . -DWITH_DEBUG=ON -DWITH_VALGRIND=ON and with default cmake/gcc/valgrind versions not showing any issues. 

.
[umshastr@hod03]/export/umesh/server/source/bugs/85993/mysql-8.0.1-dmr/mysql-test: ./mtr --debug-server --valgrind-clients mysql
Logging: ./mtr  --debug-server --valgrind-clients mysql
MySQL Version 8.0.1
Turning on valgrind for test clients
Running valgrind with options " --tool=memcheck --num-callers=16 --show-reachable=yes --suppressions=/export/umesh/server/source/bugs/85993/mysql-8.0.1-dmr/mysql-test/valgrind.supp "
Turning off --check-testcases to save time when valgrinding
Checking supported features...
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
Removing old var directory...
Creating var directory '/export/umesh/server/source/bugs/85993/mysql-8.0.1-dmr/mysql-test/var'...
Installing system database...
Using parallel: 1

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

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

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
main.mysql                               [ pass ]  157580
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 157.580 of 179 seconds executing testcases

Completed: All 1 tests were successful.

Anything else I'm missing here? 

Thanks,
Umesh
[24 Apr 2017 5:40] MySQL Verification Team
test results

Attachment: 86049.ol7.results (application/octet-stream, text), 198.51 KiB.

[24 Apr 2017 17:16] Laurynas Biveinis
Please try on Ubuntu Zesty.

Given that the stacktrace has getaddrinfo, this is probably sensitive to the libc version, compiler version, and suppressions.
[25 Apr 2017 12:19] MySQL Verification Team
Thank you Laurynas, verified now!

Thanks,
Umesh
[25 Apr 2017 12:20] MySQL Verification Team
Ubuntu Zesty 17.04 test results

Attachment: 86049.ubuntu17.04.results (application/octet-stream, text), 201.71 KiB.

[14 Aug 2017 10:08] Laurynas Biveinis
Same getaddrinfo stacktrace on 8.0.2 with main.mysql_upgrade on Ubuntu 17.04:

./mtr --debug-server --valgrind-clients --big-test mysql_upgrade
...
Upgrade process encountered error and will not continue.
==2549== 4,096 bytes in 1 blocks are definitely lost in loss record 5 of 5
==2549==    at 0x4C2DB2F: malloc (vg_replace_malloc.c:299)
==2549==    by 0x4046991: ???
==2549==    by 0x40448DB: ???
==2549==    by 0x4069060: ???
==2549==    by 0x4045DDC: ???
==2549==    by 0x66C2D6E: gaih_inet.constprop.5 (getaddrinfo.c:848)
==2549==    by 0x66C5047: getaddrinfo (getaddrinfo.c:2391)
==2549==    by 0x1E36DE: mysql_real_connect (client.cc:4505)
==2549==    by 0x2A9A9D: Mysql::Tools::Base::Options::Mysql_connection_options::create_connection() (mysql_connection_options.cc:166)
==2549==    by 0x2B069B: Mysql::Tools::Base::Abstract_connection_program::create_connection() (abstract_connection_program.cc:31)
==2549==    by 0x1D24B4: Mysql::Tools::Upgrade::Program::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) (program.cc:214)
==2549==    by 0x2ADBAF: Mysql::Tools::Base::Abstract_program::run(int, char**) (abstract_program.cc:98)
==2549==    by 0x1D1CF1: main (program.cc:1083)
==2549== 
mysqltest: At line 46: command "$MYSQL_UPGRADE --skip-verbose --force --host=not_existing_host --skip-version-check &>$MYSQL_VARDIR/foo.log" failed with wrong error: 2
[14 Aug 2017 10:26] Laurynas Biveinis
And again similar stacktrace on x.connection, editing synopsis to generalize

./mtr --debug-server --valgrind-clients --big-test --suite=x connection
...
CURRENT_TEST: x.connection
ERROR: No such host is known 'invalid'
==2934== 4,096 bytes in 1 blocks are definitely lost in loss record 145 of 145
==2934==    at 0x4C2DB2F: malloc (vg_replace_malloc.c:299)
==2934==    by 0x4046991: ???
==2934==    by 0x40448DB: ???
==2934==    by 0x4069060: ???
==2934==    by 0x4045672: ???
==2934==    by 0x4069FB0: ???
==2934==    by 0x5FC81BE: gethostbyname2_r@@GLIBC_2.2.5 (getXXbyYY_r.c:315)
==2934==    by 0x5F99E17: gaih_inet.constprop.5 (getaddrinfo.c:629)
==2934==    by 0x5F9C047: getaddrinfo (getaddrinfo.c:2391)
==2934==    by 0x32BEB0: mysqlx::XProtocol::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (mysqlx_protocol.cc:243)
==2934==    by 0x34E70E: Connection_manager::make_connection(std::shared_ptr<mysqlx::XProtocol>&) (mysqlxtest.cc:523)
==2934==    by 0x34CAEC: Connection_manager::Connection_manager(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Connection_options const&, mysqlx::Ssl_config const&, unsigned long, bool, mysqlx::Internet_protocol) (mysqlxtest.cc:347)
==2934==    by 0x3463B9: process_client_input_on_session(My_command_line_options const&, std::istream&) (mysqlxtest.cc:3401)
==2934==    by 0x34791B: main (mysqlxtest.cc:3748)
==2934== 
mysqltest: At line 159: command "$MYSQLXTEST -uroot --password='' -hinvalid -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp" failed with wrong error: 42