From 04408fff40447f9aab12aed1957356e65e1c8b15 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 12 Jan 2025 13:20:56 +1100 Subject: [PATCH] MDEV-35687 Various UBSAN function-type-mismatch debug_sync and myisam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit storage/maria/ma_open.c:352:7: runtime error: call to function debug_sync(THD*, char const*, unsigned long) through pointer to incorrect function type 'void (*)(void *, const char *, unsigned long)' The THD argument is a void *. Because of the way myisam is .c files the function prototype is mismatched. As Marko pointed out the MYSQL_THD is declared as void * in C. Thanks Jimmy HĂș for noting that struct THD is the equalivalant in C to the class THD. The C NULL was also different to the C++ nullptr. Corrected the definations of MYSQL_THD and DEBUG_SYNC_C to be C and C++ compatible. --- include/mysql/plugin.h | 3 ++- include/mysql/service_debug_sync.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index d9aef6ac11c..87efbefde68 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -44,7 +44,8 @@ class THD; class Item; #define MYSQL_THD THD* #else -#define MYSQL_THD void* +struct THD; +typedef struct THD* MYSQL_THD; #endif typedef char my_bool; diff --git a/include/mysql/service_debug_sync.h b/include/mysql/service_debug_sync.h index 0bd49a13458..f7fdbf04832 100644 --- a/include/mysql/service_debug_sync.h +++ b/include/mysql/service_debug_sync.h @@ -351,7 +351,11 @@ extern void (*debug_sync_C_callback_ptr)(MYSQL_THD, const char *, size_t); #endif /* defined(ENABLED_DEBUG_SYNC) */ /* compatibility macro */ +#ifdef __cplusplus +#define DEBUG_SYNC_C(name) DEBUG_SYNC(nullptr, name) +#else #define DEBUG_SYNC_C(name) DEBUG_SYNC(NULL, name) +#endif #ifdef __cplusplus }