-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: APIs
-
Storage Engines
-
7
-
3
-
2023-07-25 Absolute unit, StorEng - 2023-08-08, ASeasonTooMany-2023-08-22, 2024-06-11 - Dinosaurs go rawr, 2024-06-25 - Climbing BTrees
MSan reports the use-of-uninitialized-value when writing to the lock file in wiredtiger_open. This appears when running any test after building with MSan on Ubuntu 22.04. It hasn't occurred on our evergreen testing as we don't have any tasks running on 22.04 yet.
==299140==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7fa9f6a02aba in __conn_single /home/ubuntu/wiredtiger/src/conn/conn_api.c:1858:13 #1 0x7fa9f6989472 in wiredtiger_open /home/ubuntu/wiredtiger/src/conn/conn_api.c:2816:5 #2 0x5f3716 in create_database /home/ubuntu/wiredtiger/test/format/wts.c:436:5 #3 0x608e97 in wts_create_database /home/ubuntu/wiredtiger/test/format/wts.c:571:5 #4 0x5ca071 in main /home/ubuntu/wiredtiger/test/format/t.c:352:9 #5 0x7fa9f5a29d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #6 0x7fa9f5a29e3f in __libc_start_main csu/../csu/libc-start.c:392:3 #7 0x4215f4 in _start (/home/ubuntu/wiredtiger/build/test/format/t+0x4215f4)
MSan can provide more information about where the memory was allocated by enabling origins tracking. This can be enabled by adding the -fsanitize-memory-track-origins flag in modes.cmake.
# MSAN build variant flags. set(msan_link_flags "-fsanitize=memory" "-fsanitize-memory-track-origins") set(msan_compiler_c_flag "-fsanitize=memory" "-fno-optimize-sibling-calls" "-fsanitize-memory-track-origins") set(msan_compiler_cxx_flag "-fsanitize=memory" "-fno-optimize-sibling-calls" "-fsanitize-memory-track-origins")
Doing so gives the following MSan report after the warning above:
Uninitialized value was stored to memory at #0 0x7fa9f7753974 in __posix_file_size /home/ubuntu/wiredtiger/src/os_posix/os_fs.c:514:16 #1 0x7fa9f6a1fb59 in __wt_filesize /home/ubuntu/wiredtiger/src/include/os_fhandle_inline.h:138:13 #2 0x7fa9f6a02969 in __conn_single /home/ubuntu/wiredtiger/src/conn/conn_api.c:1857:9 #3 0x7fa9f6989472 in wiredtiger_open /home/ubuntu/wiredtiger/src/conn/conn_api.c:2816:5 #4 0x5f3716 in create_database /home/ubuntu/wiredtiger/test/format/wts.c:436:5 #5 0x608e97 in wts_create_database /home/ubuntu/wiredtiger/test/format/wts.c:571:5 #6 0x5ca071 in main /home/ubuntu/wiredtiger/test/format/t.c:352:9 #7 0x7fa9f5a29d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 Uninitialized value was created by an allocation of 'sb' in the stack frame of function '__posix_file_size' #0 0x7fa9f7753010 in __posix_file_size /home/ubuntu/wiredtiger/src/os_posix/os_fs.c:502