From 3a72de7b1d87b6649b997c4c99393a749d76ed0a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 1 Jun 2025 22:19:09 +1000 Subject: [PATCH 1/6] MDEV-37502: clang+debug mroonga remove -Wno-unused-but-set-variable This is frequently violated within the mroonga implementatation and therefore should not error. Reviewer: Jimmy Hu --- storage/mroonga/vendor/groonga/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt index 7364853caefb9..c1b36aee9f437 100644 --- a/storage/mroonga/vendor/groonga/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/CMakeLists.txt @@ -150,7 +150,7 @@ endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX) MY_CHECK_AND_SET_COMPILER_FLAG("-Wall") - MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-but-set-variable") + MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-error=unused-but-set-variable") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-pointer-sign") MY_CHECK_AND_SET_COMPILER_FLAG("-Wformat") MY_CHECK_AND_SET_COMPILER_FLAG("-Wstrict-aliasing=2") From fb959bfd42add4cb1f0f653c2421b7c6182a44d9 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 3 Jun 2025 16:51:16 +1000 Subject: [PATCH 2/6] MDEV-37502 mroonga + clang + Debug with exceeds stack frame size Stack limits exceeded for clang-20 +Debug + MSAN. Added disables for the following functions. storage/mroonga/vendor/groonga/lib/ii.c:303:1: error: stack frame size (16696) exceeds limit (16384) in 'buffer_segment_reserve' [-Werror,-Wframe-larger-than] 303 | buffer_segment_reserve(grn_ctx *ctx, grn_ii *ii, | ^ storage/mroonga/vendor/groonga/lib/ii.c:4803:1: error: stack frame size (20936) exceeds limit (16384) in 'grn_ii_delete_one' [-Werror,-Wframe-larger-than] 4803 | grn_ii_delete_one(grn_ctx *ctx, grn_ii *ii, grn_id tid, grn_ii_updspec *u, grn_hash *h) | ^ storage/mroonga/vendor/groonga/lib/ii.c:6313:1: error: stack frame size (25736) exceeds limit (16384) in 'grn_ii_column_update' [-Werror,-Wframe-larger-than] 6313 | grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section, | ^ For non-Debug the following stack frame sizes wher exceeded: storage/mroonga/vendor/groonga/lib/proc/proc_select.c:3575:1: warning: stack frame size (94072) exceeds limit (49152) in 'command_select' [-Wframe-larger-than] 3575 | command_select(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) | ^ storage/mroonga/vendor/groonga/lib/proc/proc_schema.c:1134:1: warning: stack frame size (98360) exceeds limit (49152) in 'command_schema_output_tables' [-Wframe-larger-than] 1134 | command_schema_output_tables(grn_ctx *ctx, grn_schema_data *data) Reviewer: Jimmy Hu --- storage/mroonga/vendor/groonga/lib/ii.c | 7 ++++--- storage/mroonga/vendor/groonga/lib/proc/proc_schema.c | 4 ++++ storage/mroonga/vendor/groonga/lib/proc/proc_select.c | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/storage/mroonga/vendor/groonga/lib/ii.c b/storage/mroonga/vendor/groonga/lib/ii.c index 761513e3b302d..87476604793e1 100644 --- a/storage/mroonga/vendor/groonga/lib/ii.c +++ b/storage/mroonga/vendor/groonga/lib/ii.c @@ -300,6 +300,8 @@ buffer_segment_new(grn_ctx *ctx, grn_ii *ii, uint32_t *segno) } } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static grn_rc buffer_segment_reserve(grn_ctx *ctx, grn_ii *ii, uint32_t *lseg0, uint32_t *pseg0, @@ -386,6 +388,8 @@ buffer_segment_reserve(grn_ctx *ctx, grn_ii *ii, return ctx->rc; } +PRAGMA_REENABLE_CHECK_STACK_FRAME + #define BGQENQUE(lseg) do {\ if (ii->header->binfo[lseg] != GRN_II_PSEG_NOT_ASSIGNED) {\ ii->header->bgqbody[ii->header->bgqhead] = ii->header->binfo[lseg];\ @@ -4529,8 +4533,6 @@ grn_ii_get_disk_usage(grn_ctx *ctx, grn_ii *ii) } -PRAGMA_DISABLE_CHECK_STACK_FRAME - #define BIT11_01(x) ((x >> 1) & 0x7ff) #define BIT31_12(x) (x >> 12) @@ -4808,7 +4810,6 @@ exit : return ctx->rc; } -PRAGMA_REENABLE_CHECK_STACK_FRAME grn_rc grn_ii_delete_one(grn_ctx *ctx, grn_ii *ii, grn_id tid, grn_ii_updspec *u, grn_hash *h) diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c b/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c index 7c632f45e5345..c755e50e3bd51 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c @@ -1130,6 +1130,8 @@ command_schema_output_table(grn_ctx *ctx, grn_ctx_output_map_close(ctx); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static void command_schema_output_tables(grn_ctx *ctx, grn_schema_data *data) { @@ -1201,6 +1203,8 @@ command_schema_output_tables(grn_ctx *ctx, grn_schema_data *data) GRN_OBJ_FIN(ctx, &table_ids); } +PRAGMA_REENABLE_CHECK_STACK_FRAME + static grn_obj * command_schema(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_select.c b/storage/mroonga/vendor/groonga/lib/proc/proc_select.c index 7588b18a17cbc..ad0e26bd2990a 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_select.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_select.c @@ -3569,7 +3569,6 @@ grn_select_data_fill_drilldowns(grn_ctx *ctx, return succeeded; } } -PRAGMA_REENABLE_CHECK_STACK_FRAME static grn_obj * command_select(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) @@ -3723,6 +3722,8 @@ exit : return NULL; } +PRAGMA_REENABLE_CHECK_STACK_FRAME + #define N_VARS 26 #define DEFINE_VARS grn_expr_var vars[N_VARS] From 292daf3992ec83f8cb9745125c4347e24f539b84 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 12 Jun 2025 18:59:43 +1000 Subject: [PATCH 3/6] MDEV-37502: mroonga+clang+debug violates its own setting of compile flags sign-compare Under Debug build this becomes a Werror. Resolved this by changing the grn_mecab_chunk_size_threshold to a ptrdiff_t along with chunked_tokenize_utf8's string_bytes argument so there is no need to case. Reviewer: Jimmy Hu --- storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c b/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c index cabf2c94e53e7..1e7216ebc00e6 100644 --- a/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c +++ b/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c @@ -37,7 +37,7 @@ static grn_plugin_mutex *sole_mecab_mutex = NULL; static grn_encoding sole_mecab_encoding = GRN_ENC_NONE; static grn_bool grn_mecab_chunked_tokenize_enabled = GRN_FALSE; -static int grn_mecab_chunk_size_threshold = 8192; +static ptrdiff_t grn_mecab_chunk_size_threshold = 8192; typedef struct { mecab_t *mecab; @@ -186,7 +186,7 @@ static grn_bool chunked_tokenize_utf8(grn_ctx *ctx, grn_mecab_tokenizer *tokenizer, const char *string, - unsigned int string_bytes) + ptrdiff_t string_bytes) { const char *chunk_start; const char *current; From e9addff01116073fe2329585aa6dcc7464596263 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 27 Aug 2025 08:01:31 +1000 Subject: [PATCH 4/6] MDEV-37502: clang/debug/rocksdb - stack frame size Follow up to MDEV-34388 82d7419e0600a70b1a1c993d33ed6cf79fbd6129 Relax limit on specific files only. clang-20 + CMAKE_BUILD_TYPE=Debug: options/cf_options.cc:0:0: stack frame size (17624) exceeds limit (16384) in function '__cxx_global_var_init.33' options/db_options.cc:0:0: stack frame size (34328) exceeds limit (32768) in function '__cxx_global_var_init.45' Reviewer: Jimmy Hu --- storage/rocksdb/CMakeLists.txt | 7 ------- storage/rocksdb/build_rocksdb.cmake | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 606a8f4039426..5f35ccbb8c0e9 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -9,13 +9,6 @@ SET(CPACK_RPM_rocksdb-engine_PACKAGE_SUMMARY "RocksDB storage engine for MariaDB SET(CPACK_RPM_rocksdb-engine_PACKAGE_DESCRIPTION "The RocksDB storage engine is a high performance storage engine, aimed at maximising storage efficiency while maintaining InnoDB-like performance." PARENT_SCOPE) -STRING(REGEX REPLACE "-Wframe-larger-than=[0-9]*" "" - CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -STRING(REGEX REPLACE "-Wframe-larger-than=[0-9]*" "" - CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") -STRING(REGEX REPLACE "-Wframe-larger-than=[0-9]*" "" - CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") -MY_CHECK_AND_SET_COMPILER_FLAG(-Wframe-larger-than=32768) MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-range-loop-construct) MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-effc++ DEBUG RELWITHDEBINFO) diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake index 1cdbad494191b..8866f26f03a1a 100644 --- a/storage/rocksdb/build_rocksdb.cmake +++ b/storage/rocksdb/build_rocksdb.cmake @@ -507,6 +507,10 @@ if(MSVC) # Workaround Win8.1 SDK bug, that breaks /permissive- string(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else() + set_source_files_properties(${ROCKSDB_SOURCE_DIR}/options/db_options.cc + PROPERTIES COMPILE_FLAGS "-Wframe-larger-than=40960") + set_source_files_properties(${ROCKSDB_SOURCE_DIR}/options/cf_options.cc + PROPERTIES COMPILE_FLAGS "-Wframe-larger-than=32768") set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul ${CXX11_FLAGS}") CHECK_CXX_SOURCE_COMPILES(" From 8fe39a31a6d187a673766a123964f534cb3fea29 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 8 Sep 2025 15:11:01 +1000 Subject: [PATCH 5/6] Revert "MDEV-36701 command line client doesn't check session_track information (fix)" This reverts commit 3e43606de6a5c6a0ee180d9c6a0ee73b2480909a. This caused Clang-18+ UBSAN errors: SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch libmariadb/libmariadb/mariadb_lib.c:2723:17 +/libmariadb/libmariadb/mariadb_lib.c:2628:3: runtime error: call to function status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*) through pointer to incorrect function type 'void (*)(void *, enum enum_mariadb_status_info, ...)' +/client/mysql.cc:3204: note: status_info_cb(void*, enum_mariadb_status_info, enum_session_state_type, st_ma_const_string*) defined here Reviewer: Jimmy Hu --- client/mysql.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 601b2df63ac8f..b9e643a12f3d0 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3199,17 +3199,20 @@ static int reconnect(void) } #ifndef EMBEDDED_LIBRARY -static void status_info_cb(void *data, enum enum_mariadb_status_info type, - enum enum_session_state_type state_type, MARIADB_CONST_STRING *val) +static void status_info_cb(void *data, enum enum_mariadb_status_info type, ...) { - if (type == SESSION_TRACK_TYPE && state_type == SESSION_TRACK_SCHEMA) + va_list ap; + va_start(ap, type); + if (type == SESSION_TRACK_TYPE && va_arg(ap, int) == SESSION_TRACK_SCHEMA) { + MARIADB_CONST_STRING *val= va_arg(ap, MARIADB_CONST_STRING *); my_free(current_db); if (val->length) current_db= my_strndup(PSI_NOT_INSTRUMENTED, val->str, val->length, MYF(MY_FAE)); else current_db= NULL; } + va_end(ap); } #else #define mysql_optionsv(A,B,C,D) do { } while(0) From c7f2de5c46e14f4f6291a214c629984fb85a502b Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 8 Sep 2025 15:19:45 +1000 Subject: [PATCH 6/6] MDEV-34388/MDEV-36701: mysql status_info_cb disable varargs warnings Clang complains that the callback is using a variadic based on an enum. client/mysql.cc:3207:16: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs] 3207 | va_start(ap, type); This is part of the C/C API this has been referred as bug: * CONC-789 MARIADB_OPT_STATUS_CALLBACK Variadic around enums is undefined behaviour In the mean time, we are just disabling the warning. Reviewer: Jimmy Hu --- client/mysql.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/mysql.cc b/client/mysql.cc index b9e643a12f3d0..50f7cb9fb9d06 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3199,6 +3199,12 @@ static int reconnect(void) } #ifndef EMBEDDED_LIBRARY +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wvarargs" +/* CONC-789 */ +#endif + static void status_info_cb(void *data, enum enum_mariadb_status_info type, ...) { va_list ap; @@ -3214,6 +3220,10 @@ static void status_info_cb(void *data, enum enum_mariadb_status_info type, ...) } va_end(ap); } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #else #define mysql_optionsv(A,B,C,D) do { } while(0) #endif