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

UBSAN: runtime error: 1e+19 is outside the range of representable values of type 'long long' in Field_bit::store on INSERT

    XMLWordPrintable

Details

    Description

      CREATE TABLE t (c BIT);
      INSERT INTO t VALUES (1e+19);  # Issue does not reproduce with <19
      

      Leads to:

      CS 10.5.28 a226f12675c6312ca7632b90261397e313e6a7ae (Optimized, UBASAN, Clang)

      /test/10.5_opt_san/sql/field.cc:9926:38: runtime error: 1e+19 is outside the range of representable values of type 'long long'
      SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow /test/10.5_opt_san/sql/field.cc:9926:38 
          #0 0x55cc6bc42b72 in Field_bit::store(double) /test/10.5_opt_san/sql/field.cc:9926:38
          #1 0x55cc6bc42b72 in Field_bit_as_char::store(double) /test/10.5_opt_san/sql/field.h:5107:53
          #2 0x55cc6aae4de8 in fill_record(THD*, TABLE*, Field**, List<Item>&, bool, bool, bool) /test/10.5_opt_san/sql/sql_base.cc:8836:18
          #3 0x55cc6aae63b0 in fill_record_n_invoke_before_triggers(THD*, TABLE*, Field**, List<Item>&, bool, trg_event_type) /test/10.5_opt_san/sql/sql_base.cc:8891:11
          #4 0x55cc6ac01bcd in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item>>&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /test/10.5_opt_san/sql/sql_insert.cc:1072:13
          #5 0x55cc6adbf51b in mysql_execute_command(THD*) /test/10.5_opt_san/sql/sql_parse.cc:4664:10
          #6 0x55cc6ad80e98 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_opt_san/sql/sql_parse.cc:8251:18
          #7 0x55cc6ad739d0 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_opt_san/sql/sql_parse.cc:1891:7
          #8 0x55cc6ad838d9 in do_command(THD*) /test/10.5_opt_san/sql/sql_parse.cc:1375:17
          #9 0x55cc6b48b5c2 in do_handle_one_connection(CONNECT*, bool) /test/10.5_opt_san/sql/sql_connect.cc:1386:11
          #10 0x55cc6b48aa24 in handle_one_connection /test/10.5_opt_san/sql/sql_connect.cc:1298:5
          #11 0x55cc6a7eb10c in asan_thread_start(void*) asan_interceptors.cpp.o
          #12 0x14b32469ca93 in start_thread nptl/pthread_create.c:447:8
          #13 0x14b324729c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow /test/10.5_opt_san/sql/field.cc:9926:38 
      

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18:
           # 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
      

      Bug confirmed present in:
      MariaDB: 10.5.28 (dbg), 10.5.28 (opt), 10.6.21 (dbg), 10.6.21 (opt), 10.11.11 (dbg), 10.11.11 (opt), 11.4.5 (dbg), 11.4.5 (opt), 11.7.1 (dbg), 11.7.1 (opt), 11.8.0 (dbg), 11.8.0 (opt)

      Attachments

        Activity

          People

            bar Alexander Barkov
            Roel Roel Van de Paar
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.