Bug #81674 LeakSanitizer-enabled build fails to bootstrap server for MTR
Submitted: 1 Jun 2016 11:12 Modified: 21 Jul 2016 13:22
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.6.30, 5.6.31 OS:Any
Assigned to: CPU Architecture:Any
Tags: asan, bootstrap, lsan, mtr

[1 Jun 2016 11:12] Laurynas Biveinis
Description:
If the server is built with AddressSanitizer support on a system where LeakSanitizer is enabled too, the resulting server will fail to bootstrap server for MTR

How to repeat:
cmake ... -DWITH_ASAN=ON ...
# Workaround http://bugs.mysql.com/bug.php?id=80014
ASAN_OPTIONS="detect_leaks=0" make -j5
...
$ ./mtr --debug-server 1st
...
Installing system database...
mysql-test-run: *** ERROR: Error executing mysqld --bootstrap
...
var/log/bootstrap.log:

=================================================================
==4792==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x7ff89b72054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x1479423 in ut_malloc_low(unsigned long, unsigned long) /home/laurynas/mysql-server/storage/innobase/ut/ut0mem.cc:104
    #2 0x147b9eb in rbt_create(unsigned long, int (*)(void const*, void const*)) /home/laurynas/mysql-server/storage/innobase/ut/ut0rbt.cc:802
    #3 0x150e7c7 in buf_flush_init_flush_rbt() /home/laurynas/mysql-server/storage/innobase/buf/buf0flu.cc:309
    #4 0x1265654 in recv_sys_init(unsigned long) /home/laurynas/mysql-server/storage/innobase/log/log0recv.cc:394
    #5 0x13fcf86 in innobase_start_or_create_for_mysql() /home/laurynas/mysql-server/storage/innobase/srv/srv0start.cc:2087
    #6 0x11a0857 in innobase_init /home/laurynas/mysql-server/storage/innobase/handler/ha_innodb.cc:3428
    #7 0x5b77ee in ha_initialize_handlerton(st_plugin_int*) /home/laurynas/mysql-server/sql/handler.cc:662
    #8 0x9cbfd6 in plugin_initialize /home/laurynas/mysql-server/sql/sql_plugin.cc:1137
    #9 0x9d8f21 in plugin_init(int*, char**, int) /home/laurynas/mysql-server/sql/sql_plugin.cc:1431
    #10 0x59a8f0 in init_server_components /home/laurynas/mysql-server/sql/mysqld.cc:4866
    #11 0x59a8f0 in mysqld_main(int, char**) /home/laurynas/mysql-server/sql/mysqld.cc:5463
    #12 0x57e50e in main /home/laurynas/mysql-server/sql/main.cc:25
    #13 0x7ff89a1e382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7ff89b72054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x1479423 in ut_malloc_low(unsigned long, unsigned long) /home/laurynas/mysql-server/storage/innobase/ut/ut0mem.cc:104
    #2 0x147ba2e in rbt_create(unsigned long, int (*)(void const*, void const*)) /home/laurynas/mysql-server/storage/innobase/ut/ut0rbt.cc:808
    #3 0x150e7c7 in buf_flush_init_flush_rbt() /home/laurynas/mysql-server/storage/innobase/buf/buf0flu.cc:309
    #4 0x1265654 in recv_sys_init(unsigned long) /home/laurynas/mysql-server/storage/innobase/log/log0recv.cc:394
    #5 0x13fcf86 in innobase_start_or_create_for_mysql() /home/laurynas/mysql-server/storage/innobase/srv/srv0start.cc:2087
    #6 0x11a0857 in innobase_init /home/laurynas/mysql-server/storage/innobase/handler/ha_innodb.cc:3428
    #7 0x5b77ee in ha_initialize_handlerton(st_plugin_int*) /home/laurynas/mysql-server/sql/handler.cc:662
    #8 0x9cbfd6 in plugin_initialize /home/laurynas/mysql-server/sql/sql_plugin.cc:1137
    #9 0x9d8f21 in plugin_init(int*, char**, int) /home/laurynas/mysql-server/sql/sql_plugin.cc:1431
    #10 0x59a8f0 in init_server_components /home/laurynas/mysql-server/sql/mysqld.cc:4866
    #11 0x59a8f0 in mysqld_main(int, char**) /home/laurynas/mysql-server/sql/mysqld.cc:5463
    #12 0x57e50e in main /home/laurynas/mysql-server/sql/main.cc:25
    #13 0x7ff89a1e382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7ff89b72054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x1479423 in ut_malloc_low(unsigned long, unsigned long) /home/laurynas/mysql-server/storage/innobase/ut/ut0mem.cc:104
    #2 0x147bae9 in rbt_create(unsigned long, int (*)(void const*, void const*)) /home/laurynas/mysql-server/storage/innobase/ut/ut0rbt.cc:816
    #3 0x150e7c7 in buf_flush_init_flush_rbt() /home/laurynas/mysql-server/storage/innobase/buf/buf0flu.cc:309
    #4 0x1265654 in recv_sys_init(unsigned long) /home/laurynas/mysql-server/storage/innobase/log/log0recv.cc:394
    #5 0x13fcf86 in innobase_start_or_create_for_mysql() /home/laurynas/mysql-server/storage/innobase/srv/srv0start.cc:2087
    #6 0x11a0857 in innobase_init /home/laurynas/mysql-server/storage/innobase/handler/ha_innodb.cc:3428
    #7 0x5b77ee in ha_initialize_handlerton(st_plugin_int*) /home/laurynas/mysql-server/sql/handler.cc:662
    #8 0x9cbfd6 in plugin_initialize /home/laurynas/mysql-server/sql/sql_plugin.cc:1137
    #9 0x9d8f21 in plugin_init(int*, char**, int) /home/laurynas/mysql-server/sql/sql_plugin.cc:1431
    #10 0x59a8f0 in init_server_components /home/laurynas/mysql-server/sql/mysqld.cc:4866
    #11 0x59a8f0 in mysqld_main(int, char**) /home/laurynas/mysql-server/sql/mysqld.cc:5463
    #12 0x57e50e in main /home/laurynas/mysql-server/sql/main.cc:25
    #13 0x7ff89a1e382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 136 byte(s) leaked in 3 allocation(s).
[1 Jun 2016 11:13] Laurynas Biveinis
A 5.6-only issue; 5.5 and 5.7 bootstrap OK
[7 Jun 2016 9:39] MySQL Verification Team
Hello Laurynas,

Thank you for the report.
Observed this with 5.6.31 source build.

Thanks,
Umesh
[7 Jun 2016 9:40] MySQL Verification Team
Build log and test results

Attachment: 81674_5.6.31.build_log (application/octet-stream, text), 141.63 KiB.

[21 Jul 2016 13:22] Laurynas Biveinis
The fix would be to backport [1]. Then, running MTR with LeakSanitiser uncovers a few other minor bugs.

[1]:

commit 30a08cf60cfa08655f553da2795b68eee8dba53c
Author: Vasil Dimov <vasil.dimov@oracle.com>
Date:   Thu May 15 15:07:12 2014 +0300

    Fix Bug#18253089 BUF_POOL->FLUSH_RBT IS CREATED WHEN RECOVERY IS NOT NEEDED,
    THEN NEVER FREED
    
    * recv_recovery_from_checkpoint_start() is only called from
      innobase_start_or_create_for_mysql() and
      recv_recovery_from_checkpoint_start() calls recv_sys_create()&recv_sys_init()
      but those two functions have already been called earlier in
      innobase_start_or_create_for_mysql(). Those two functions return immediately
      if recv_sys is created/initialized. From this follows that their invokations
      from recv_recovery_from_checkpoint_start() are noops and thus I am removing
      them.
    
    * The code used to initialize buf_pool->flush_rbt (buf_flush_init_flush_rbt())
      from recv_sys_init(). Change this so that it is initialized directly from
      recv_recovery_from_checkpoint_start(). This is the only functional change
      in this patch - buf_pool->flush_rbt will now be initialized later in the
      startup code path.
    
    * The code used to free buf_pool->flush_rbt (buf_flush_free_flush_rbt()) from
      recv_sys_debug_free(). Change this so that the free is done from
      recv_recovery_from_checkpoint_finish(), which is the only caller of
      recv_sys_debug_free(). This is a noop, but made for consistency wrt where
      alloc/free is done - call
      buf_flush_init_flush_rbt() from recv_recovery_from_checkpoint_start() and
      buf_flush_free_flush_rbt() from recv_recovery_from_checkpoint_finish().
    
    This way the code will be restored as of before
    annamalai.gurusami@oracle.com-20140210082850-vqlzadis1asdws0e (the fix of
    Bug#18144349 INNODB CANNOT USE THE DOUBLEWRITE BUFFER FOR THE FIRST PAGE OF
    SYSTEM TABLESPACE) wrt buf_pool->flush_rbt initialization.
    
    Approved by:    Yasufumi (rb:5409)