Skip to content

Commit 3944655

Browse files
committed
MDEV-37019 MSAN_STAT_WORKAROUND macro remove
MSAN has been updated since 2022 when this macro was added and as such the working around MSAN's deficient understanding of the fstat/stat syscall behaviour at the time is no longer required. As an effective no-op a straight removal is sufficient.
1 parent 4be442e commit 3944655

File tree

11 files changed

+1
-35
lines changed

11 files changed

+1
-35
lines changed

extra/mariabackup/fil_cur.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ xb_fil_cur_open(
186186
}
187187
#else
188188
err = fstat(cursor->file.m_file, &cursor->statinfo);
189-
MSAN_STAT_WORKAROUND(&cursor->statinfo);
190189
#endif
191190
if (max_file_size < (ulonglong)cursor->statinfo.st_size) {
192191
cursor->statinfo.st_size = (ulonglong)max_file_size;

extra/mariabackup/xtrabackup.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4160,7 +4160,6 @@ os_file_readdir_next_file(
41604160
return(-1);
41614161
}
41624162

4163-
MSAN_STAT_WORKAROUND(&statinfo);
41644163
info->size = statinfo.st_size;
41654164

41664165
if (S_ISDIR(statinfo.st_mode)) {

include/my_valgrind.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
3838
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
3939
# define REDZONE_SIZE 8
40-
# ifdef __linux__
41-
# define MSAN_STAT_WORKAROUND(st) MEM_MAKE_DEFINED(st, sizeof(*st))
42-
# else
43-
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
44-
# endif
4540
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
4641
# include <valgrind/memcheck.h>
4742
# define HAVE_MEM_CHECK
@@ -54,7 +49,6 @@
5449
# define MEM_GET_VBITS(a,b,len) VALGRIND_GET_VBITS(a,b,len)
5550
# define MEM_SET_VBITS(a,b,len) VALGRIND_SET_VBITS(a,b,len)
5651
# define REDZONE_SIZE 8
57-
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
5852
#elif defined(__SANITIZE_ADDRESS__) && (!defined(_MSC_VER) || defined (__clang__))
5953
# include <sanitizer/asan_interface.h>
6054
/* How to do manual poisoning:
@@ -68,7 +62,6 @@
6862
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
6963
# define MEM_GET_VBITS(a,b,len) ((void) 0)
7064
# define MEM_SET_VBITS(a,b,len) ((void) 0)
71-
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
7265
# define REDZONE_SIZE 8
7366
#else
7467
# define MEM_UNDEFINED(a,len) ((void) 0)
@@ -80,7 +73,6 @@
8073
# define MEM_GET_VBITS(a,b,len) ((void) 0)
8174
# define MEM_SET_VBITS(a,b,len) ((void) 0)
8275
# define REDZONE_SIZE 0
83-
# define MSAN_STAT_WORKAROUND(st) ((void) 0)
8476
#endif /* __has_feature(memory_sanitizer) */
8577

8678
#ifdef TRASH_FREED_MEMORY

mysys/my_lib.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,6 @@ int my_fstat(File Filedes, MY_STAT *stat_area,
334334
DBUG_PRINT("my",("fd: %d MyFlags: %lu", Filedes, MyFlags));
335335
#ifdef _WIN32
336336
DBUG_RETURN(my_win_fstat(Filedes, stat_area));
337-
#elif defined HAVE_valgrind
338-
{
339-
int s= fstat(Filedes, stat_area);
340-
if (!s)
341-
MSAN_STAT_WORKAROUND(stat_area);
342-
DBUG_RETURN(s);
343-
}
344337
#else
345338
DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area));
346339
#endif
@@ -361,7 +354,6 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
361354
#ifndef _WIN32
362355
if (!stat((char *) path, (struct stat *) stat_area))
363356
{
364-
MSAN_STAT_WORKAROUND(stat_area);
365357
DBUG_RETURN(stat_area);
366358
}
367359
#else

mysys/my_symlink.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ int my_is_symlink(const char *filename __attribute__((unused)))
115115
struct stat stat_buff;
116116
if (lstat(filename, &stat_buff))
117117
return 0;
118-
MSAN_STAT_WORKAROUND(&stat_buff);
119118
return !!S_ISLNK(stat_buff.st_mode);
120119
#elif defined (_WIN32)
121120
DWORD dwAttr = GetFileAttributes(filename);

sql/datadict.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
162162
if (mysql_file_fstat(file, &state, MYF(MY_WME)))
163163
goto err;
164164

165-
MSAN_STAT_WORKAROUND(&state);
166-
167165
if (mysql_file_seek(file, 0, SEEK_SET, MYF(MY_WME)))
168166
goto err;
169167

sql/discover.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int readfrm(const char *name, const uchar **frmdata, size_t *len)
7272
error= 2;
7373
if (mysql_file_fstat(file, &state, MYF(0)))
7474
goto err;
75-
MSAN_STAT_WORKAROUND(&state);
75+
7676
read_len= (size_t)MY_MIN(FRM_MAX_SIZE, state.st_size); // safety
7777

7878
// Read whole frm file

sql/parse_file.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,6 @@ sql_parse_prepare(const LEX_CSTRING *file_name, MEM_ROOT *mem_root,
465465
DBUG_RETURN(0);
466466
}
467467

468-
MSAN_STAT_WORKAROUND(&stat_info);
469-
470468
if (stat_info.st_size > INT_MAX-1)
471469
{
472470
my_error(ER_FPARSER_TOO_BIG_FILE, MYF(0), file_name->str);

storage/innobase/log/log0log.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,9 @@ static void *log_mmap(os_file_t file,
284284
struct stat st;
285285
if (!fstat(file, &st))
286286
{
287-
MSAN_STAT_WORKAROUND(&st);
288287
const auto st_dev= st.st_dev;
289288
if (!stat("/dev/shm", &st))
290289
{
291-
MSAN_STAT_WORKAROUND(&st);
292290
is_pmem= st.st_dev == st_dev;
293291
if (!is_pmem)
294292
return ptr; /* MAP_FAILED */

storage/innobase/os/os0file.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,6 @@ os_file_status_posix(
865865

866866
if (!ret) {
867867
/* file exists, everything OK */
868-
MSAN_STAT_WORKAROUND(&statinfo);
869868
} else if (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) {
870869
/* file does not exist */
871870
return(true);
@@ -1039,7 +1038,6 @@ static ATTRIBUTE_COLD void os_file_log_buffered()
10391038
/** @return whether the log file may work with unbuffered I/O. */
10401039
static ATTRIBUTE_COLD bool os_file_log_maybe_unbuffered(const struct stat &st)
10411040
{
1042-
MSAN_STAT_WORKAROUND(&st);
10431041
char b[20 + sizeof "/sys/dev/block/" ":" "/../queue/physical_block_size"];
10441042
if (snprintf(b, sizeof b, "/sys/dev/block/%u:%u/queue/physical_block_size",
10451043
major(st.st_dev), minor(st.st_dev)) >=
@@ -1443,7 +1441,6 @@ os_file_size_t os_file_get_size(const char *filename) noexcept
14431441
int ret = stat(filename, &s);
14441442

14451443
if (ret == 0) {
1446-
MSAN_STAT_WORKAROUND(&s);
14471444
file_size.m_total_size = s.st_size;
14481445
/* st_blocks is in 512 byte sized blocks */
14491446
file_size.m_alloc_size = s.st_blocks * 512;
@@ -1488,8 +1485,6 @@ os_file_get_status_posix(
14881485
return(DB_FAIL);
14891486
}
14901487

1491-
MSAN_STAT_WORKAROUND(statinfo);
1492-
14931488
switch (statinfo->st_mode & S_IFMT) {
14941489
case S_IFDIR:
14951490
stat_info->type = OS_FILE_TYPE_DIR;
@@ -3754,7 +3749,6 @@ void fil_node_t::find_metadata(IF_WIN(,bool create)) noexcept
37543749
struct stat statbuf;
37553750
if (!fstat(file, &statbuf))
37563751
{
3757-
MSAN_STAT_WORKAROUND(&statbuf);
37583752
block_size= statbuf.st_blksize;
37593753
# ifdef __linux__
37603754
on_ssd= fil_system.is_ssd(statbuf.st_dev);

0 commit comments

Comments
 (0)