Bug #91845 Memory leak after running rpl.rpl_ssl MTR test case detected by Valgrind
Submitted: 31 Jul 2018 12:21 Modified: 31 Jul 2018 14:30
Reporter: Yura Sorokin (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Tests: Replication Severity:S7 (Test Cases)
Version:5.5.61 OS:Any
Assigned to: CPU Architecture:Any

[31 Jul 2018 12:21] Yura Sorokin
Description:
Valgrind report excerpt

3,892 (8 direct, 3,884 indirect) bytes in 1 blocks are definitely lost in loss record 122 of 139
   at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x6875AA: my_malloc (my_malloc.c:38)
   by 0x92F5E8: new_VioSSLFd (viosslfactories.c:219)
   by 0x92FD8F: new_VioSSLConnectorFd (viosslfactories.c:326)
   by 0x50E649: send_client_reply_packet (client.c:2697)
   by 0x50EC7C: client_mpvio_write_packet (client.c:2876)
   by 0x50D5AC: native_password_auth_client (client.c:4501)
   by 0x511236: run_plugin_auth (client.c:3033)
   by 0x5127F5: mysql_real_connect (client.c:3636)
   by 0x513B7B: mysql_reconnect (client.c:3737)
   by 0x513FFC: cli_advanced_command (client.c:852)
   by 0x512ACE: mysql_close (client.c:3949)
   by 0x39F09C: handle_slave_io (slave.cc:3108)
   by 0x8EF6D6: pfs_spawn_thread (pfs.cc:1015)
   by 0x54816DA: start_thread (pthread_create.c:463)
   by 0x5EE688E: clone (clone.S:95)

How to repeat:
Build MySQL Server 5.5.61 with bundled SSL library (YaSSL) on a recent Linux (Ubuntu Bionic).

Apply the attached GCC 7.3 patch.

cmake \
 $SRC_DIR \
 -DCMAKE_BUILD_TYPE=Debug \
 -DBUILD_CONFIG=mysql_release \
 -DFEATURE_SET=community \
 -DMYSQL_MAINTAINER_MODE=ON \
 -DWITH_SSL=bundled \
 -DWITH_VALGRIND=ON

Run
./mtr --debug-server --valgrind rpl.rpl_ssl

Suggested fix:
Looks like the descriptor created with new_VioSSLConnectorFd() is never deleted in some unsuccessful code paths.
[31 Jul 2018 12:34] Yura Sorokin
GCC 7.3 fix for 5.5

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: mysql_5_5_gcc_7_3_fix.diff (application/octet-stream, text), 806 bytes.

[31 Jul 2018 14:30] MySQL Verification Team
Hello Yura,

Thank you for the report!

Thanks,
Umesh