From b331cde26be8d6db73f530a8689fe5b79dec9d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Sep 2024 14:34:08 +0300 Subject: [PATCH] MDEV-34921 MemorySanitizer reports errors for non-debug builds my_b_encr_write(): Initialize also block_length, and at the same time last_block_length, so that all 128 bits can be initialized with fewer writes. This fixes an error that was caught in the test encryption.tempfiles_encrypted. test_my_safe_print_str(): Skip a test that would attempt to display uninitialized data in the test unit.stacktrace. Previously, our CI did not build unit tests with MemorySanitizer. handle_delayed_insert(): Remove a redundant call to pthread_exit(0), which would for some reason cause MemorySanitizer in clang-19 to report a stack overflow in a RelWithDebInfo build. This fixes a failure of several tests. Reviewed by: Vladislav Vaintroub --- sql/mf_iocache_encr.cc | 4 ++-- sql/sql_insert.cc | 1 - unittest/mysys/stacktrace-t.c | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sql/mf_iocache_encr.cc b/sql/mf_iocache_encr.cc index 63830ec620a..3175226a3d1 100644 --- a/sql/mf_iocache_encr.cc +++ b/sql/mf_iocache_encr.cc @@ -175,8 +175,8 @@ static int my_b_encr_write(IO_CACHE *info, const uchar *Buffer, size_t Count) DBUG_RETURN(info->error= -1); } crypt_data->counter= 0; - - IF_DBUG(crypt_data->block_length= 0,); + crypt_data->block_length= 0; + crypt_data->last_block_length= 0; } do diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 46486e09a8b..875ae9f9c63 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3498,7 +3498,6 @@ pthread_handler_t handle_delayed_insert(void *arg) DBUG_LEAVE; } my_thread_end(); - pthread_exit(0); return 0; } diff --git a/unittest/mysys/stacktrace-t.c b/unittest/mysys/stacktrace-t.c index d8408f80d76..c8b699ca696 100644 --- a/unittest/mysys/stacktrace-t.c +++ b/unittest/mysys/stacktrace-t.c @@ -30,7 +30,7 @@ void test_my_safe_print_str() memcpy(b_bss, "LEGAL", 6); #ifdef HAVE_STACKTRACE -#ifndef __SANITIZE_ADDRESS__ +# if !defined __SANITIZE_ADDRESS__ && !__has_feature(memory_sanitizer) fprintf(stderr, "\n===== stack =====\n"); my_safe_print_str(b_stack, 65535); fprintf(stderr, "\n===== heap =====\n"); @@ -40,15 +40,15 @@ void test_my_safe_print_str() fprintf(stderr, "\n===== data =====\n"); my_safe_print_str("LEGAL", 65535); fprintf(stderr, "\n===== Above is a junk, but it is expected. =====\n"); -#endif /*__SANITIZE_ADDRESS__*/ +# endif fprintf(stderr, "\n===== Nornal length test =====\n"); my_safe_print_str("LEGAL", 5); fprintf(stderr, "\n===== NULL =====\n"); my_safe_print_str(0, 5); -#ifndef __SANITIZE_ADDRESS__ +# ifndef __SANITIZE_ADDRESS__ fprintf(stderr, "\n===== (const char*) 1 =====\n"); my_safe_print_str((const char*)1, 5); -#endif /*__SANITIZE_ADDRESS__*/ +# endif /*__SANITIZE_ADDRESS__*/ #endif /*HAVE_STACKTRACE*/ free(b_heap);