Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-5114

Enable running WiredTiger with clang MemorySanitizer

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 4.3 Desired
    • Component/s: None
    • Labels:
      None

      Description

      It would be useful if we could run WiredTiger with clang MemorySanitizer:
      https://releases.llvm.org/3.7.0/tools/clang/docs/MemorySanitizer.html

      It is possible to build with Memory Sanitizer at the moment, use CC="clang -fsanitize=memory" with your configure command and a clang that supports memory sanitizer.

      Running test/format immediately flags failures though, the first I encountered was:

      Uninitialized bytes in __interceptor_pwrite at offset 64 inside [0x71c000004000, 1024)
      ==333==WARNING: MemorySanitizer: use-of-uninitialized-value
          #0 0x7cb479 in __posix_file_write /home/alexg/work/wiredtiger/build_posix/../src/os_posix/os_fs.c:546:19
          #1 0xbae14f in __wt_write /home/alexg/work/wiredtiger/build_posix/../src/include/os_fhandle.i:180:11
          #2 0xba9cf0 in __block_write_off /home/alexg/work/wiredtiger/build_posix/../src/block/block_write.c:332:16
          #3 0xba7971 in __wt_block_write_off /home/alexg/work/wiredtiger/build_posix/../src/block/block_write.c:392:11
          #4 0xba7090 in __wt_block_write /home/alexg/work/wiredtiger/build_posix/../src/block/block_write.c:200:5
          #5 0xb6f068 in __bm_write /home/alexg/work/wiredtiger/build_posix/../src/block/block_mgr.c:504:7
          #6 0x541e2c in __wt_bt_write /home/alexg/work/wiredtiger/build_posix/../src/btree/bt_io.c:348:5
          #7 0x848d46 in __rec_split_write /home/alexg/work/wiredtiger/build_posix/../src/reconcile/rec_write.c:1989:5
          #8 0x844ad8 in __wt_rec_split /home/alexg/work/wiredtiger/build_posix/../src/reconcile/rec_write.c:1298:9
          #9 0x84dae7 in __wt_rec_split_crossing_bnd /home/alexg/work/wiredtiger/build_posix/../src/reconcile/rec_write.c:1391:13
          #10 0x1198606 in __wt_bulk_insert_row /home/alexg/work/wiredtiger/build_posix/../src/reconcile/rec_row.c:222:9
          #11 0x128adf3 in __curbulk_insert_row /home/alexg/work/wiredtiger/build_posix/../src/cursor/cur_bulk.c:258:11
          #12 0x1119489 in __clsm_insert_bulk /home/alexg/work/wiredtiger/build_posix/../src/lsm/lsm_cursor_bulk.c:78:5
          #13 0x499f73 in wts_load /home/alexg/work/wiredtiger/build_posix/test/format/../../../test/format/bulk.c:164:20
          #14 0x4e1433 in main /home/alexg/work/wiredtiger/build_posix/test/format/../../../test/format/t.c:198:9
          #15 0x7fd64d3cdb96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
          #16 0x41c5f9 in _start (/mnt/data0/alexg/work/wiredtiger/build_posix/test/format/t+0x41c5f9)
       
      SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/alexg/work/wiredtiger/build_posix/../src/os_posix/os_fs.c:546:19 in __posix_file_write
      Exiting
      

      I believe we don't care about that issue (it's expected behavior), but the recommended approach for ignoring false alarms didn't work when I tried it:

      --- a/build_posix/aclocal/strict.m4
      +++ b/build_posix/aclocal/strict.m4
      @@ -101,6 +101,7 @@ AC_DEFUN([AM_GCC_WARNINGS], [
       AC_DEFUN([AM_CLANG_WARNINGS], [
              w="-Weverything -Werror"
       
      +       w="$w -Wno-gcc-compat"
              w="$w -Wno-cast-align"
              w="$w -Wno-documentation-unknown-command"
              w="$w -Wno-format-nonliteral"
      diff --git a/src/os_posix/os_fs.c b/src/os_posix/os_fs.c
      index dfa075d12..f541db1c2 100644
      --- a/src/os_posix/os_fs.c
      +++ b/src/os_posix/os_fs.c
      @@ -510,6 +510,13 @@ __posix_file_truncate(WT_FILE_HANDLE *file_handle, WT_SESSION *wt_session, wt_of
       }
       #endif
       
      +static int __posix_file_write(WT_FILE_HANDLE *, WT_SESSION *, wt_off_t, size_t, const void *)
      +#if defined(__has_feature)
      +    #if __has_feature(memory_sanitizer)
      +       __attribute__((no_sanitize_memory))
      +    #endif
      +#endif
      +       ;
       /*
        * __posix_file_write --
        *     POSIX pwrite.
      
      

      I suspect I'm not using the __attribute__ correctly.

        Attachments

          Activity

            People

            • Assignee:
              backlog-server-storage-engines Backlog - Storage Engines Team
              Reporter:
              alexander.gorrod Alexander Gorrod
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: