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

Fix memory leak in wt load

    • Storage Engines
    • 5
    • 2023-03-21 Ellen Ripley, 2023-04-04 Bibbidi-Bobbidi-Boo, 2023-05-16 Chook-n-Nuts Farm
    • v7.0

      A mongo sanitizer test hit a LeakSanitizer: detected memory leaks error after switching to a new build variant that now includes an address sanitizer. The leak appears in the load command when using the wt utility.

      The call stack from the sanitizer in the BF:

      [js_test:validate_bson_inconsistency] sh13605| =================================================================
      [js_test:validate_bson_inconsistency] sh13605| ==13605==ERROR: LeakSanitizer: detected memory leaks
      [js_test:validate_bson_inconsistency] sh13605|
      [js_test:validate_bson_inconsistency] sh13605| Direct leak of 40 byte(s) in 1 object(s) allocated from:
      [js_test:validate_bson_inconsistency] sh13605|     #0 0x5565d0fb4b54 in strdup /data/mci/4c5523d6b930f0c1f82f5452d6add3b6/toolchain-builder/tmp/build-llvm-v4.sh-FAX/llvm-project-llvmorg/compiler-rt/lib/asan/asan_interceptors.cpp:437:3
      [js_test:validate_bson_inconsistency] sh13605|     #1 0x5565d1002df4 in config_read /data/mci/da608b724433f1de477969d78cce27ee/src/src/third_party/wiredtiger/src/utilities/util_load.c:305:28
      [js_test:validate_bson_inconsistency] sh13605|     #2 0x5565d1002df4 in load_dump /data/mci/da608b724433f1de477969d78cce27ee/src/src/third_party/wiredtiger/src/utilities/util_load.c:127:16
      [js_test:validate_bson_inconsistency] sh13605|     #3 0x5565d1002df4 in util_load /data/mci/da608b724433f1de477969d78cce27ee/src/src/third_party/wiredtiger/src/utilities/util_load.c:105:13
      [js_test:validate_bson_inconsistency] sh13605|     #4 0x5565d100ab70 in main /data/mci/da608b724433f1de477969d78cce27ee/src/src/third_party/wiredtiger/src/utilities/util_main.c:333:11
      [js_test:validate_bson_inconsistency] sh13605|     #5 0x7f9d68311812 in __libc_start_main (/lib64/libc.so.6+0x23812)
      [js_test:validate_bson_inconsistency] sh13605|
      [js_test:validate_bson_inconsistency] sh13605| Objects leaked above:
      [js_test:validate_bson_inconsistency] sh13605| 0x6040000063d0 (40 bytes)
      [js_test:validate_bson_inconsistency] sh13605|
      [js_test:validate_bson_inconsistency] sh13605| SUMMARY: AddressSanitizer: 40 byte(s) leaked in 1 allocation(s).
      [js_test:validate_bson_inconsistency] 2023-03-15T19:16:46.796Z assert: [6] != [0] are not equal : error executing: wt -h /data/db/job0/mongorunner/validate_bson_inconsistency load -f /data/db/job0/mongorunner/validate_bson_inconsistency/new_table_file0 -r collection-4--8812987538576048916
      

      I've been able to reproduce a similar sanitizer error when running wt load on an example database from test/format after building with the cmake flag -DCMAKE_BUILD_TYPE=ASan.

      ubuntu@ip-10-0-95-27:/data/mci/artifacts-27c04f-ubuntu2004-asan_compile/cmake_build/test/format$ ../../wt -h RUNDIR/ load -f table1_dump.txt       
      =================================================================
      ==9221==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00000288cc00 in thread T0
          #0 0x49495d in free (/data/mci/artifacts-27c04f-ubuntu2004-asan_compile/cmake_build/wt+0x49495d)
          #1 0x4cc8e4 in load_dump /data/mci/e86c5ffb3edf5b9243f8190e38acef06/wiredtiger/src/utilities/util_load.c:179:9
          #2 0x4cc56d in util_load /data/mci/e86c5ffb3edf5b9243f8190e38acef06/wiredtiger/src/utilities/util_load.c:105:13
          #3 0x4c4fbd in main /data/mci/e86c5ffb3edf5b9243f8190e38acef06/wiredtiger/src/utilities/util_main.c:333:11
          #4 0x7fc659797082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
          #5 0x41c49d in _start (/data/mci/artifacts-27c04f-ubuntu2004-asan_compile/cmake_build/wt+0x41c49d)
      
      Address 0x00000288cc00 is a wild pointer.
      SUMMARY: AddressSanitizer: bad-free (/data/mci/artifacts-27c04f-ubuntu2004-asan_compile/cmake_build/wt+0x49495d) in free
      ==9221==ABORTING
      Aborted (core dumped)
      

      We need to fix this memory leak.

            Assignee:
            will.korteland@mongodb.com Will Korteland
            Reporter:
            sean.watt@mongodb.com Sean Watt
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: