-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-35554/ MDEV-33158 UBSAN runtime error: call to function show_cached_thread_count() (and plugin interface) #3737
base: 10.5
Are you sure you want to change the base?
Conversation
through pointer to incorrect function type. The argument is void* rather than char*. This shows up with UBSAN testing under clang.
In plugins, use the correct resolver for ULONG and ULONGLONG types. InnoDB has a UINT type as evidenced by "Unknown variable type code 0x182 in plugin 'InnoDB'." so the implemntation for UNSIGNED INT was added.
8116295
to
50ebc21
Compare
The mismatch occurs on the function calls as in the sql/sql_udf.h the types of "error" and "is_null" are unsigned char rather than char. This is corrected for the udf functions: * spider_direct_sql * spider_direct_bg_sql * spider_flush_table_mon_cache * spider_copy_tables * spider_ping_table
6dcbc88
to
d85cd2a
Compare
The spider commit (d85cd2a) lgtm, thanks for the fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @grooverdan !
The first two commits look good, thanks! I left a couple minor notes to consider. Also, I am leaving the third commit for @mariadb-YuchenPei to review.
@@ -3227,6 +3227,11 @@ static int *mysql_sys_var_int(THD* thd, int offset) | |||
return (int *) intern_sys_var_ptr(thd, offset, true); | |||
} | |||
|
|||
static unsigned int *mysql_sys_var_uint(THD* thd, int offset) | |||
{ | |||
return (unsigned int *) intern_sys_var_ptr(thd, offset, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of C-style casts in this area, though it's cpp code. Perhaps now would be a good time to refactor them to the proper casting style.
@@ -714,8 +714,8 @@ int spider_udf_bg_copy_exec_sql( | |||
long long spider_copy_tables_body( | |||
UDF_INIT *initid, | |||
UDF_ARGS *args, | |||
char *is_null, | |||
char *error | |||
unsigned char *is_null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the MDEV-35735 JIRA you mention
performed manual testing in UBSAN environment as its not completely runable in mtr:
I'd say that'd be good to mention in the commit message too (along with the test case, and also some more detail on why you couldn't use MTR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although now after some of my own attempts to reproduce/test the issue (which I couldn't actually reproduce the error following the JIRA commands), I now see @mariadb-YuchenPei is assigned to review the spider changes, so I'll let him take over for this part.
case PLUGIN_VAR_BOOL: | ||
((thdvar_bool_t *) opt)->resolve= mysql_sys_var_char; | ||
break; | ||
case PLUGIN_VAR_INT: | ||
((thdvar_int_t *) opt)->resolve= mysql_sys_var_int; | ||
break; | ||
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED: | ||
((thdvar_uint_t *) opt)->resolve= mysql_sys_var_uint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in the second commit message (for MDEV-33158), it'd be good to re-mention the MTR tests that verify the fixes, as you do on JIRA.
Description
clang/UBSAN shows this up as an error as the argument is incorrect.
The argument is void* rather than char*.
Release Notes
not required.
How can this PR be tested?
basic bootstrap when compiled WITH_UBSAN under clang.
If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.
Basing the PR against the correct MariaDB version
main
branch.PR quality check