MDEV-35687 Various UBSAN function-type-mismatch debug_sync and myisam

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.
This commit is contained in:
Daniel Black 2025-01-12 13:20:56 +11:00
parent 6e86fe0063
commit 04408fff40
2 changed files with 6 additions and 1 deletions

View file

@ -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;

View file

@ -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
}