Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35738

MariaDB cannot be compiled with -fsanitize=pointer-compare due to two invalid pointer pairs

Details

    Description

      MariaDB cannot currently be Clang, ASAN compiled with -fsanitize=address,pointer-compare

      During compilation with this flag, the following two invalid-pointer-pair issues are observed:

      CS 95975b921e900551240ac28457e28efb6d02c1bb (Debug, UBASAN, Clang)

      ==731607==ERROR: AddressSanitizer: invalid-pointer-pair: 0x7fff37f7cde8 0xfffffffffffffff0
          #0 0x55fb72d27fbb in main /test/10.11_opt_san/scripts/comp_sql.c:129:22
          #1 0x14c298e2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #2 0x14c298e2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #3 0x55fb72c4c5f4 in _start (/test/10.11_opt_san/scripts/comp_sql+0x2d5f4) (BuildId: 1e0b9f54a6ed127ec7099f41a54a19335c14cbe3)
       
      Address 0x7fff37f7cde8 is located in stack of thread T0
      Address 0xfffffffffffffff0 is a wild pointer inside of access range of size 0x000000000001.
      SUMMARY: AddressSanitizer: invalid-pointer-pair /test/10.11_opt_san/scripts/comp_sql.c:129:22 in main
      ==731607==ABORTING
      

      CS 95975b921e900551240ac28457e28efb6d02c1bb (Debug, UBASAN, Clang)

      ==731826==ERROR: AddressSanitizer: invalid-pointer-pair: 0x7ffe34af435c 0xfffffffffffffff2
          #0 0x5623a95a286d in process_option /test/10.11_opt_san/strings/uca-dump.c:422:31
          #1 0x5623a95a2e34 in process_options /test/10.11_opt_san/strings/uca-dump.c:468:11
          #2 0x5623a95a4010 in main /test/10.11_opt_san/strings/uca-dump.c:749:7
          #3 0x154b26c2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #4 0x154b26c2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #5 0x5623a94c9364 in _start (/test/10.11_opt_san/strings/uca-dump+0x2f364) (BuildId: b782b0bf5d5e72a27b6ca829ad10a605170d96cf)
       
      Address 0x7ffe34af435c is located in stack of thread T0
      Address 0xfffffffffffffff2 is a wild pointer inside of access range of size 0x000000000001.
      SUMMARY: AddressSanitizer: invalid-pointer-pair /test/10.11_opt_san/strings/uca-dump.c:422:31 in process_option
      ==731826==ABORTING
      

      Likely affects other versions also.

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18. Ubuntu instructions:
           # Note: llvm-17-linker-tools installs /usr/lib/llvm-17/lib/LLVMgold.so, which is needed for compilation, and LLVMgold.so is no longer included in LLVM 18
           sudo apt install clang llvm-18 llvm-18-linker-tools llvm-18-runtime llvm-18-tools llvm-18-dev libstdc++-14-dev llvm-dev llvm-17-linker-tools
           sudo ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
      Compiled with: '-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++' and:
          -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWSREP_LIB_WITH_ASAN=ON
      Set before execution:
          export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1   # And you may also want to supress UBSAN startup issues using 'suppressions=UBSAN.filter'. For an example of UBSAN.filter, which includes current startup issues see: https://github.com/mariadb-corporation/mariadb-qa/blob/master/UBSAN.filter
      

      Attachments

        Activity

          Roel Roel Van de Paar added a comment - - edited

          As far as I understand, these errors are caused by invalid pointer comparisons involving a wild pointer (e.g., 0xfffffffffffffff0 or 0xfffffffffffffff2)

          Roel Roel Van de Paar added a comment - - edited As far as I understand, these errors are caused by invalid pointer comparisons involving a wild pointer (e.g., 0xfffffffffffffff0 or 0xfffffffffffffff2)
          Roel Roel Van de Paar added a comment - - edited

          Found two possible workarounds:
          1. An ASAN supression filter with:

          interceptor_via_lib:comp_sql.c
          interceptor_via_fun:process_option
          

          Set before compilation via something like:

          export ASAN_OPTIONS=suppressions=/some_path/ASAN.filter
          

          2. Or, during compilation, temporarily set:

          export ASAN_OPTIONS=detect_invalid_pointer_pairs=0
          

          Roel Roel Van de Paar added a comment - - edited Found two possible workarounds: 1. An ASAN supression filter with: interceptor_via_lib:comp_sql.c interceptor_via_fun:process_option Set before compilation via something like: export ASAN_OPTIONS=suppressions= /some_path/ASAN .filter 2. Or, during compilation, temporarily set: export ASAN_OPTIONS=detect_invalid_pointer_pairs=0

          People

            danblack Daniel Black
            Roel Roel Van de Paar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.