Bug #85995 Server error exit due to empty datadir causes LeakSanitizer errors
Submitted: 19 Apr 2017 2:53 Modified: 25 Oct 2018 10:27
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.1 OS:Any
Assigned to: CPU Architecture:Any

[19 Apr 2017 2:53] Laurynas Biveinis
Description:
On a system where AddressSanitizer includes LeakSanitizer, e.g. recent Ubuntu:

cmake ... -DWITH_DEBUG=ON -DWITH_ASAN
...
./mtr --debug-server dd_bootstrap --big-test
...
main.dd_bootstrap                        [ fail ]
        Test ended at 2017-04-19 05:44:28

CURRENT_TEST: main.dd_bootstrap
mysqltest: At line 128: command "$MYSQLD $extra_args --datadir=$DDIR" failed with wrong error: 1
...

var/tmp/server.log then contains

2017-04-19T02:44:22.541563Z 1 [ERROR] InnoDB: Cannot continue operation.

=================================================================
==1596==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1179504 byte(s) in 8191 object(s) allocated from:
    #0 0x7f9ec4fccec0 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc6ec0)
    #1 0x563500a257f9 in ut_allocator<unsigned char>::allocate(unsigned long, unsigned char const*, char const*, bool, bool) (/home/laurynas/obj-8.0-asan-debug-openssl/sql/mysqld
-debug+0x27f37f9)
    #2 0x563500ba8e5c in os_event_create(char const*) /home/laurynas/mysql-server/storage/innobase/os/os0event.cc:458
    #3 0x563500dbf2fb in rw_lock_create_func(rw_lock_t*, latch_level_t, char const*, char const*, unsigned long) /home/laurynas/mysql-server/storage/innobase/sync/sync0rw.cc:276
    #4 0x563500f78823 in pfs_rw_lock_create_func /home/laurynas/mysql-server/storage/innobase/include/sync0rw.ic:677
    #5 0x563500f78823 in buf_block_init /home/laurynas/mysql-server/storage/innobase/buf/buf0buf.cc:842
    #6 0x563500f78823 in buf_chunk_init /home/laurynas/mysql-server/storage/innobase/buf/buf0buf.cc:944
    #7 0x563500f79edd in buf_pool_init_instance /home/laurynas/mysql-server/storage/innobase/buf/buf0buf.cc:1158
    #8 0x563500f79edd in buf_pool_init(unsigned long, unsigned long) /home/laurynas/mysql-server/storage/innobase/buf/buf0buf.cc:1347
    #9 0x563500daaabb in srv_start(bool) /home/laurynas/mysql-server/storage/innobase/srv/srv0start.cc:1776
    #10 0x5635009e233e in innobase_init_files /home/laurynas/mysql-server/storage/innobase/handler/ha_innodb.cc:4397
    #11 0x5635009e233e in innobase_dict_init /home/laurynas/mysql-server/storage/innobase/handler/ha_innodb.cc:11916
    #12 0x5634ff5a6b90 in DDSE_dict_init /home/laurynas/mysql-server/sql/dd/impl/bootstrapper.cc:330
    #13 0x5634ff5ace3b in dd::bootstrap::upgrade_do_pre_checks_and_initialize_dd(THD*) /home/laurynas/mysql-server/sql/dd/impl/bootstrapper.cc:1332
    #14 0x5634ffa5a186 in handle_bootstrap /home/laurynas/mysql-server/sql/bootstrap.cc:333
    #15 0x5635012e224c in pfs_spawn_thread /home/laurynas/mysql-server/storage/perfschema/pfs.cc:2407
    #16 0x7f9ec4cef6d9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76d9)
... lots more ...

Leaving Category non-specific, not sure if this should be considered InnoDB or test environment.

How to repeat:
See above

Suggested fix:
Suppress LeakSanitizer reporting when server fails to start?
[19 Apr 2017 5:58] MySQL Verification Team
Hello Laurynas,

Thank you for the report.

Thanks,
Umesh
[25 Oct 2018 10:27] Erlend Dahl
Duplicate of

Bug#80637 SQL layer should call innobase_shutdown() if dict_init() fails