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

UBSAN: runtime error: load of value 21/58, which is not a valid value for type 'bool' in extract_date_time

    XMLWordPrintable

Details

    Description

      SELECT STR_TO_DATE(0,'%Y -% m-%d % H:%i:%S.%f');
      

      Leads to:

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/sql/item_timefunc.cc:143:8: runtime error: load of value 21, which is not a valid value for type 'bool'
      /test/10.5_dbg_san/sql/item_timefunc.cc:144:8: runtime error: load of value 58, which is not a valid value for type 'bool'
          #0 0x5637f1c81577 in extract_date_time(THD*, st_date_time_format*, char const*, unsigned int, st_mysql_time*, enum_mysql_timestamp_type, char const**, char const*, date_conv_mode_t) /test/10.5_dbg_san/sql/item_timefunc.cc:143:8
          #1 0x5637f1c80cf7 in Item_func_str_to_date::get_date_common(THD*, st_mysql_time*, date_mode_t, enum_mysql_timestamp_type) /test/10.5_dbg_san/sql/item_timefunc.cc:3125:7
          #2 0x5637f1ca52de in Func_handler_str_to_date_datetime_usec::get_date(THD*, Item_handled_func*, st_mysql_time*, date_mode_t) const /test/10.5_dbg_san/sql/item_timefunc.h:1718:14
          #3 0x5637f0667ceb in Item_handled_func::get_date(THD*, st_mysql_time*, date_mode_t) /test/10.5_dbg_san/sql/item_func.h:838:28
          #4 0x5637f05febde in Type_handler::Item_send_datetime(Item*, Protocol*, st_value*) const /test/10.5_dbg_san/sql/sql_type.cc:7647:9
          #5 0x5637eff0d67c in Type_handler_datetime_common::Item_send(Item*, Protocol*, st_value*) const /test/10.5_dbg_san/sql/sql_type.h:6553:12
          #6 0x5637ee5ed977 in Item::send(Protocol*, st_value*) /test/10.5_dbg_san/sql/item.h:1083:28
          #7 0x5637ee5c2871 in Protocol::send_result_set_row(List<Item>*) /test/10.5_dbg_san/sql/protocol.cc:1086:15
          #8 0x5637eec21fca in select_send::send_data(List<Item>&) /test/10.5_dbg_san/sql/sql_class.cc:3161:17
          #9 0x5637ef4a32f0 in select_result_sink::send_data_with_check(List<Item>&, st_select_lex_unit*, unsigned long long) /test/10.5_dbg_san/sql/sql_class.h:5580:12
          #10 0x5637ef49d76c in JOIN::exec_inner() /test/10.5_dbg_san/sql/sql_select.cc:4529:22
          #11 0x5637ef4998d1 in JOIN::exec() /test/10.5_dbg_san/sql/sql_select.cc:4441:3
          #12 0x5637ef348543 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /test/10.5_dbg_san/sql/sql_select.cc:4918:9
          #13 0x5637ef3440c7 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
          #14 0x5637ef1203f0 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6437:12
          #15 0x5637ef0b459f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4029:12
          #16 0x5637ef05b4e3 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8237:18
          #17 0x5637ef03b453 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #18 0x5637ef063a19 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #19 0x5637effddf30 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #20 0x5637effdc6fd in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #21 0x5637ee4d7a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #22 0x153ad749ca93 in start_thread nptl/pthread_create.c:447:8
          #23 0x153ad7529c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: invalid-bool-load /test/10.5_dbg_san/sql/item_timefunc.cc:144:8
      

      Setup:

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

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

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.5.28 (opt), 10.6.21 (opt), 10.11.11 (opt), 11.4.5 (opt), 11.7.1 (opt), 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.