Recently, MSAN_OPTIONS=poison_in_dtor=1 was enabled by default. This caught some foul play in InnoDB (to be fixed in MDEV-30936) as well as massive amounts of failures in free_root(), because the root->used or root->free lists could be marked as uninitialized in various destructors for objects that are allocated from a MEM_ROOT.
It would be good programming style to make sure that MemorySanitizer does not report any errors when MSAN_OPTIONS=poison_in_dtor=1 is set.
It is possible to work around the errors with the following patch:
I think that explicitly setting MSAN_OPTIONS=poison_in_dtor=0 when using Clang 15 or later is a lesser evil. The above patch could mask other errors as well.
#13 0x557ba143d208 in do_command(THD*) /mariadb/10.5/sql/sql_parse.cc:1375:17
#14 0x557ba1aa472e in do_handle_one_connection(CONNECT*, bool) /mariadb/10.5/sql/sql_connect.cc:1416:11
#15 0x557ba1aa3e47 in handle_one_connection /mariadb/10.5/sql/sql_connect.cc:1318:5
#16 0x557ba22fe547 in pfs_spawn_thread /mariadb/10.5/storage/perfschema/pfs.cc:2201:3
#17 0x7f4934887fd3 in start_thread nptl/pthread_create.c:442:8
#18 0x7f493490866b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Uninitialized value was stored to memory at
#0 0x557ba055cec9 in __msan_memcpy (/dev/shm/10.5msan/sql/mariadbd+0xfc7ec9) (BuildId: 54a87c1c8e383aaa)
#1 0x557ba12cafff in Server_side_cursor::operator delete(void*, unsigned long) /mariadb/10.5/sql/sql_cursor.cc:206:22
#2 0x557ba12cafff in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:396:1
Memory was marked as uninitialized
#0 0x557ba0563cfd in __sanitizer_dtor_callback (/dev/shm/10.5msan/sql/mariadbd+0xfcecfd) (BuildId: 54a87c1c8e383aaa)
#1 0x557ba12caf0d in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:399:1
Marko Mäkelä
added a comment - With a proper MSAN_SYMBOLIZER_PATH wrapper script (see MDEV-30936 ), we can get nice traces:
10.5 402f36dd652b57a48d2d3e18949f5d7a1450363d
==2878081==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x557ba37746de in free_root /mariadb/10.5/mysys/my_alloc.c:418:3
#1 0x557ba12cb046 in Server_side_cursor::operator delete(void*, unsigned long) /mariadb/10.5/sql/sql_cursor.cc:216:3
#2 0x557ba12cb046 in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:396:1
#3 0x557ba0f49607 in sp_cursor::destroy() /mariadb/10.5/sql/sp_rcontext.cc:783:3
#4 0x557ba0f49607 in sp_cursor::close(THD*) /mariadb/10.5/sql/sp_rcontext.cc:776:3
#5 0x557ba0f27ca4 in sp_instr_cclose::execute(THD*, unsigned int*) /mariadb/10.5/sql/sp_head.cc:4561:13
#6 0x557ba0efa7b4 in sp_head::execute(THD*, bool) /mariadb/10.5/sql/sp_head.cc:1438:20
#7 0x557ba0f033c6 in sp_head::execute_procedure(THD*, List<Item>*) /mariadb/10.5/sql/sp_head.cc:2450:5
#8 0x557ba144caf3 in do_execute_sp(THD*, sp_head*) /mariadb/10.5/sql/sql_parse.cc:3089:16
#9 0x557ba144bdc4 in Sql_cmd_call::execute(THD*) /mariadb/10.5/sql/sql_parse.cc:3335:9
#10 0x557ba1452955 in mysql_execute_command(THD*) /mariadb/10.5/sql/sql_parse.cc:6061:26
#11 0x557ba143bb06 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /mariadb/10.5/sql/sql_parse.cc:8091:18
#12 0x557ba14311ec in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /mariadb/10.5/sql/sql_parse.cc:1891:7
#13 0x557ba143d208 in do_command(THD*) /mariadb/10.5/sql/sql_parse.cc:1375:17
#14 0x557ba1aa472e in do_handle_one_connection(CONNECT*, bool) /mariadb/10.5/sql/sql_connect.cc:1416:11
#15 0x557ba1aa3e47 in handle_one_connection /mariadb/10.5/sql/sql_connect.cc:1318:5
#16 0x557ba22fe547 in pfs_spawn_thread /mariadb/10.5/storage/perfschema/pfs.cc:2201:3
#17 0x7f4934887fd3 in start_thread nptl/pthread_create.c:442:8
#18 0x7f493490866b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Uninitialized value was stored to memory at
#0 0x557ba055cec9 in __msan_memcpy (/dev/shm/10.5msan/sql/mariadbd+0xfc7ec9) (BuildId: 54a87c1c8e383aaa)
#1 0x557ba12cafff in Server_side_cursor::operator delete(void*, unsigned long) /mariadb/10.5/sql/sql_cursor.cc:206:22
#2 0x557ba12cafff in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:396:1
Memory was marked as uninitialized
#0 0x557ba0563cfd in __sanitizer_dtor_callback (/dev/shm/10.5msan/sql/mariadbd+0xfcecfd) (BuildId: 54a87c1c8e383aaa)
#1 0x557ba12caf0d in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:399:1
With a proper MSAN_SYMBOLIZER_PATH wrapper script (see
MDEV-30936), we can get nice traces:10.5 402f36dd652b57a48d2d3e18949f5d7a1450363d
==2878081==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x557ba37746de in free_root /mariadb/10.5/mysys/my_alloc.c:418:3
#1 0x557ba12cb046 in Server_side_cursor::operator delete(void*, unsigned long) /mariadb/10.5/sql/sql_cursor.cc:216:3
#2 0x557ba12cb046 in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:396:1
#3 0x557ba0f49607 in sp_cursor::destroy() /mariadb/10.5/sql/sp_rcontext.cc:783:3
#4 0x557ba0f49607 in sp_cursor::close(THD*) /mariadb/10.5/sql/sp_rcontext.cc:776:3
#5 0x557ba0f27ca4 in sp_instr_cclose::execute(THD*, unsigned int*) /mariadb/10.5/sql/sp_head.cc:4561:13
#6 0x557ba0efa7b4 in sp_head::execute(THD*, bool) /mariadb/10.5/sql/sp_head.cc:1438:20
#7 0x557ba0f033c6 in sp_head::execute_procedure(THD*, List<Item>*) /mariadb/10.5/sql/sp_head.cc:2450:5
#8 0x557ba144caf3 in do_execute_sp(THD*, sp_head*) /mariadb/10.5/sql/sql_parse.cc:3089:16
#9 0x557ba144bdc4 in Sql_cmd_call::execute(THD*) /mariadb/10.5/sql/sql_parse.cc:3335:9
#10 0x557ba1452955 in mysql_execute_command(THD*) /mariadb/10.5/sql/sql_parse.cc:6061:26
#11 0x557ba143bb06 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /mariadb/10.5/sql/sql_parse.cc:8091:18
#12 0x557ba14311ec in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /mariadb/10.5/sql/sql_parse.cc:1891:7
#13 0x557ba143d208 in do_command(THD*) /mariadb/10.5/sql/sql_parse.cc:1375:17
#14 0x557ba1aa472e in do_handle_one_connection(CONNECT*, bool) /mariadb/10.5/sql/sql_connect.cc:1416:11
#15 0x557ba1aa3e47 in handle_one_connection /mariadb/10.5/sql/sql_connect.cc:1318:5
#16 0x557ba22fe547 in pfs_spawn_thread /mariadb/10.5/storage/perfschema/pfs.cc:2201:3
#17 0x7f4934887fd3 in start_thread nptl/pthread_create.c:442:8
#18 0x7f493490866b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Uninitialized value was stored to memory at
#0 0x557ba055cec9 in __msan_memcpy (/dev/shm/10.5msan/sql/mariadbd+0xfc7ec9) (BuildId: 54a87c1c8e383aaa)
#1 0x557ba12cafff in Server_side_cursor::operator delete(void*, unsigned long) /mariadb/10.5/sql/sql_cursor.cc:206:22
#2 0x557ba12cafff in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:396:1
Memory was marked as uninitialized
#0 0x557ba0563cfd in __sanitizer_dtor_callback (/dev/shm/10.5msan/sql/mariadbd+0xfcecfd) (BuildId: 54a87c1c8e383aaa)
#1 0x557ba12caf0d in Materialized_cursor::~Materialized_cursor() /mariadb/10.5/sql/sql_cursor.cc:399:1