Skip to content

Commit

Permalink
Created a workaround for a bug in MSAN for va_arg(,double)
Browse files Browse the repository at this point in the history
MDEV-22691 MSAN use-of-uninitialized-value in test maria.maria-recovery2

This caused all my_vsnprintf() using doubles to fail.
Thanks to the workaround, I was able to remove the disabling of
MSAN in dtoa().
  • Loading branch information
montywi committed Jun 14, 2020
1 parent d7a9cdc commit e843033
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 0 additions & 3 deletions strings/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -2168,9 +2168,6 @@ static int quorem(Bigint *b, Bigint *S)

static char *dtoa(double dd, int mode, int ndigits, int *decpt, int *sign,
char **rve, char *buf, size_t buf_size)
#if __has_feature(memory_sanitizer)
__attribute__((no_sanitize("memory"))) // FIXME: dd is claimed uninitialized
#endif
{
/*
Arguments ndigits, decpt, sign are similar to those
Expand Down
6 changes: 6 additions & 0 deletions strings/my_vsnprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,13 @@ size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
}
else if (*fmt == 'f' || *fmt == 'g')
{
#if __has_feature(memory_sanitizer) /* QQ: MSAN has double trouble? */
__msan_check_mem_is_initialized(ap, sizeof(double));
#endif
double d= va_arg(ap, double);
#if __has_feature(memory_sanitizer) /* QQ: MSAN has double trouble? */
__msan_unpoison(&d, sizeof(double));
#endif
to= process_dbl_arg(to, end, width, d, *fmt);
continue;
}
Expand Down

0 comments on commit e843033

Please sign in to comment.