From df414933f1962a0956931453fe3a8b93afd017cc Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 23 May 2025 20:02:45 +1000 Subject: [PATCH] MDEV-36316/MDEV-36327/MDEV-36328 Debug msan Clang ~16+ on MSAN became quite strict with uninitalized data being passed and returned from functions. Non-debug builds have a basic optimization that hides these from those builds Two innodb cases violate the assumptions, however once inlined with a basic optimization those that existed for uninitialized values are removed. (MDEV-36316) rec_set_bit_field_2 calling mach_read_from_2 hits a read of bits it wasn't actually changing. (MDEV-36327) The function dict_process_sys_columns_rec left nth_v_col uninitialized unless it was a virtual column. This was ok as the function i_s_sys_columns_fill_table also didn't read this value unless it was a virtual column. --- extra/CMakeLists.txt | 8 ++++++++ storage/innobase/CMakeLists.txt | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index 06dc8900968..00fe76433ca 100644 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -82,6 +82,14 @@ IF(WITH_INNOBASE_STORAGE_ENGINE) ) + # clang ~16+ with return values being undefined is resolved by basic optimization + # compiler flags for the function mach_read_from_2 (per MDEV-36316) + IF(WITH_MSAN AND CMAKE_BUILD_TYPE STREQUAL "Debug") + SET_SOURCE_FILES_PROPERTIES( + ${INNOBASE_SOURCES} + innochecksum.cc + PROPERTIES COMPILE_FLAGS -Og) + ENDIF() MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.cc ${INNOBASE_SOURCES}) TARGET_LINK_LIBRARIES(innochecksum mysys mysys_ssl) ADD_DEPENDENCIES(innochecksum GenError) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 37b2703e171..122cdb73342 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -473,6 +473,42 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" ) ENDIF() +# clang ~16+ with return values being uninitialized is resolved by basic optimization +# compiler flags. The inlining of these function means the uninitalized paths are +# elimated from mach_read_from_2 (per MDEV-36316) and i_s_dict_fill_sys_columns MDEV-36327 +IF(WITH_MSAN AND CMAKE_BUILD_TYPE STREQUAL "Debug") + SET_SOURCE_FILES_PROPERTIES( + btr/btr0btr.cc + btr/btr0bulk.cc + data/data0data.cc + dict/dict0load.cc + dict/dict0mem.cc + fil/fil0crypt.cc + fil/fil0pagecompress.cc + fsp/fsp0fsp.cc + fut/fut0lst.cc + gis/gis0rtree.cc + handler/ha_innodb.cc + handler/i_s.cc + ibuf/ibuf0ibuf.cc + log/log0recv.cc + page/page0cur.cc + page/page0page.cc + page/page0zip.cc + rem/rem0rec.cc + row/row0import.cc + row/row0mysql.cc + row/row0purge.cc + row/row0uins.cc + row/row0undo.cc + row/row0upd.cc + trx/trx0purge.cc + trx/trx0rec.cc + trx/trx0trx.cc + trx/trx0undo.cc + PROPERTIES COMPILE_FLAGS -Og) +ENDIF() + # Older gcc version insist on -mhtm flag for including the # htmxlintrin.h header. This is also true for new gcc versions # like 11.2.0 in Debian Sid