Bug #75682 Memory leak when user tries to install dll plugin in Linux
Submitted: 29 Jan 2015 18:39 Modified: 20 Feb 2015 22:14
Reporter: Nuno Carvalho Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Windows Severity:S3 (Non-critical)
Version:5.7.6 OS:Any
Assigned to: CPU Architecture:Any

[29 Jan 2015 18:39] Nuno Carvalho
Description:
rpl.rpl_replication_observers_example_plugin_server_startup_win validates that server startup hooks are run on server start on Windows. There is also a Linux version.

The test contains the following lines:
> --source include/windows.inc
> --source extra/rpl_tests/rpl_replication_observers_example_plugin_server_startup.inc
First one, skip the test on other platforms then Windows.
Second one, include the test itself.

The test rpl_replication_observers_example_plugin_server_startup_win-master.opt contains:
> $RPL_OBS_EXAMPLE_OPT
> --plugin-load=replication_observers_example_plugin.dll
We need to start the server with plugin installed so that plugin
receives server start notifications.

Everything is OK, test works as expected on Windows.
On Linux as well, server complains that cannot install a dll as expected:
> [ERROR] Can't open shared library '.../mysql-trunk/BIN-VALGRIND/INSTALL/lib/plugin/replication_observers_example_plugin.dll' (errno: 38 .../mysql-trunk/BIN-VALGRIND/INSTALL/lib/plugin/replication_observers_exampl)

The problem is that Valgrind reports a memory leak:
> worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
> rpl.rpl_replication_observers_example_plugin_server_startup_win [ skipped ]  Need windows
> worker[1] Valgrind report from .../mysql-trunk/BIN-VALGRIND/INSTALL/mysql-test/var/log/mysqld.1.err after tests:
>  rpl.rpl_replication_observers_example_plugin_server_startup_win
> --------------------------------------------------------------------------
> HEAP SUMMARY:
>     in use at exit: 187,816 bytes in 262 blocks
>   total heap usage: 216,205 allocs, 215,943 frees, 171,899,937 bytes allocated
>
> 200 bytes in 1 blocks are still reachable in loss record 44 of 50
>    at 0x4C27BE0: realloc (vg_replace_malloc.c:662)
>    by 0x609E912: vasprintf (in /lib64/libc-2.12.so)
>    by 0x607EC87: asprintf (in /lib64/libc-2.12.so)
>    by 0x5485506: dlerror (in /lib64/libdl-2.12.so)
>    by 0x1022D02: plugin_dl_add(st_mysql_lex_string const*, int) (sql_plugin.cc:540)
>    by 0x1026068: plugin_load_list(st_mem_root*, int*, char**, char const*) (sql_plugin.cc:1666)
>    by 0x10255B0: plugin_init(int*, char**, int) (sql_plugin.cc:1453)
>    by 0xB27590: init_server_components() (mysqld.cc:4063)
>    by 0xB286AF: mysqld_main(int, char**) (mysqld.cc:4619)
>    by 0xB1FE83: main (main.cc:25)

How to repeat:
Run rpl.rpl_replication_observers_example_plugin_server_startup_win on Valgrind.

./mtr  --debug-server --mem --valgrind --valgrind-option=--gen-suppressions=all --valgrind-option=--show-reachable=yes --mysqld=--binlog-format=mixed rpl.rpl_replication_observers_example_plugin_server_startup_win
[20 Feb 2015 22:14] Paul DuBois
Noted in 5.7.6 changelog.

On Linux, trying to install a .dll plugin (intended for Windows)
resulted in a memory leak.