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

use-of-uninitialized-value 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)

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      DO STR_TO_DATE(1,'%#');
      

      Leads to:

      CS 10.6.28 4f66ca1b69daf1b7e6a562ca8e86d77a6a70abfe (Debug, MSAN, Clang 20.1.8-20250804) Build 01/08/2026

      ==3039331==WARNING: MemorySanitizer: use-of-uninitialized-value
          #0 0x5f7d05cef137 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/msan_slow_src/10.6_dbg_msan/sql/item_timefunc.cc:348:9
          #1 0x5f7d05cec779 in Item_func_str_to_date::get_date_common(THD*, st_mysql_time*, date_mode_t, enum_mysql_timestamp_type) /test/msan_slow_src/10.6_dbg_msan/sql/item_timefunc.cc:3932:7
          #2 0x5f7d06946ab3 in Type_handler_temporal_with_date::Item_update_null_value(Item*) const /test/msan_slow_src/10.6_dbg_msan/sql/sql_type.cc:4273:16
          #3 0x5f7d059ffc28 in Item_func::is_null() /test/msan_slow_src/10.6_dbg_msan/sql/item_func.h:248:5
          #4 0x5f7d062b00e6 in mysql_do(THD*, List<Item>&) /test/msan_slow_src/10.6_dbg_msan/sql/sql_do.cc:36:19
          #5 0x5f7d06283b73 in mysql_execute_command(THD*, bool) /test/msan_slow_src/10.6_dbg_msan/sql/sql_parse.cc:4041:10
          #6 0x5f7d06273e08 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/msan_slow_src/10.6_dbg_msan/sql/sql_parse.cc:8199:18
          #7 0x5f7d0626d82e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/msan_slow_src/10.6_dbg_msan/sql/sql_parse.cc:1911:7
          #8 0x5f7d06274914 in do_command(THD*, bool) /test/msan_slow_src/10.6_dbg_msan/sql/sql_parse.cc:1421:17
          #9 0x5f7d06746edc in do_handle_one_connection(CONNECT*, bool) /test/msan_slow_src/10.6_dbg_msan/sql/sql_connect.cc:1393:11
          #10 0x5f7d067467e9 in handle_one_connection /test/msan_slow_src/10.6_dbg_msan/sql/sql_connect.cc:1305:5
          #11 0x7e4cf129cb83 in start_thread nptl/pthread_create.c:447:8
          #12 0x7e4cf1329d6b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
        Uninitialized value was created by an allocation of 'val_string' in the stack frame
          #0 0x5f7d05cec219 in Item_func_str_to_date::get_date_common(THD*, st_mysql_time*, date_mode_t, enum_mysql_timestamp_type) /test/msan_slow_src/10.6_dbg_msan/sql/item_timefunc.cc:3922:3
       
      SUMMARY: MemorySanitizer: use-of-uninitialized-value /test/msan_slow_src/10.6_dbg_msan/sql/item_timefunc.cc:348:9 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)
      

      CS 10.6.28 4f66ca1b69daf1b7e6a562ca8e86d77a6a70abfe (Optimized, MSAN, Clang 20.1.8-20250804) Build 01/08/2026

      ==3039346==WARNING: MemorySanitizer: use-of-uninitialized-value
          #0 0x574a6032d63b 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/msan_slow_src/10.6_opt_msan/sql/item_timefunc.cc:348:9
          #1 0x574a6032addb in Item_func_str_to_date::get_date_common(THD*, st_mysql_time*, date_mode_t, enum_mysql_timestamp_type) /test/msan_slow_src/10.6_opt_msan/sql/item_timefunc.cc:3932:7
          #2 0x574a60ef9bc3 in Type_handler_temporal_with_date::Item_update_null_value(Item*) const /test/msan_slow_src/10.6_opt_msan/sql/sql_type.cc:4273:16
          #3 0x574a60066ae8 in Item_func::is_null() /test/msan_slow_src/10.6_opt_msan/sql/item_func.h:248:5
          #4 0x574a60896ac6 in mysql_do(THD*, List<Item>&) /test/msan_slow_src/10.6_opt_msan/sql/sql_do.cc:36:19
          #5 0x574a6086d8f2 in mysql_execute_command(THD*, bool) /test/msan_slow_src/10.6_opt_msan/sql/sql_parse.cc:4041:10
          #6 0x574a60860075 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/msan_slow_src/10.6_opt_msan/sql/sql_parse.cc:8199:18
          #7 0x574a6085a12b in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/msan_slow_src/10.6_opt_msan/sql/sql_parse.cc:1911:7
          #8 0x574a60860c68 in do_command(THD*, bool) /test/msan_slow_src/10.6_opt_msan/sql/sql_parse.cc:1421:17
          #9 0x574a60cfab7c in do_handle_one_connection(CONNECT*, bool) /test/msan_slow_src/10.6_opt_msan/sql/sql_connect.cc:1393:11
          #10 0x574a60cfa4a2 in handle_one_connection /test/msan_slow_src/10.6_opt_msan/sql/sql_connect.cc:1305:5
          #11 0x7bac4649cb83 in start_thread nptl/pthread_create.c:447:8
          #12 0x7bac46529d6b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
        Uninitialized value was created by an allocation of 'val_string' in the stack frame
          #0 0x574a6032a899 in Item_func_str_to_date::get_date_common(THD*, st_mysql_time*, date_mode_t, enum_mysql_timestamp_type) /test/msan_slow_src/10.6_opt_msan/sql/item_timefunc.cc:3922:3
       
      SUMMARY: MemorySanitizer: use-of-uninitialized-value /test/msan_slow_src/10.6_opt_msan/sql/item_timefunc.cc:348:9 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)
      

      Setup:

      Compiled with a recent version of Clang and LLVM. Ubuntu instructions for Clang/LLVM 18:
        # Note: It is strongly recommended to uninstall all old Clang & LLVM packages (ref  dpkg --list | grep -iE 'clang|llvm'  and use  apt purge  and  dpkg --purge  to remove the packages), before installing Clang/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 lld-18
      Compiled with: "-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C{,XX}_FLAGS='-O1 -march=native -mtune=native'" and:
          -DWITH_MSAN=ON  # Note: WITH_MSAN=ON is auto-ignored when not using clang (MDEV-20377)
      Set before execution:
          export MSAN_OPTIONS=abort_on_error=1:poison_in_dtor=0
      

      MSAN Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.6   dbg  010826  4f66ca1b69daf1b7e6a562ca8e86d77a6a70abfe  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  10.6   opt  010826  4f66ca1b69daf1b7e6a562ca8e86d77a6a70abfe  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  10.11  dbg  010826  1dab253482dd562457c89deb68082fb647572959  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  10.11  opt  010826  1dab253482dd562457c89deb68082fb647572959  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  11.4   dbg  010826  c57069561c4fe8f72191d4a2a4a829e5b57537dc  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  11.4   opt  010826  c57069561c4fe8f72191d4a2a4a829e5b57537dc  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  11.8   dbg  010826  eaca80bf3208fb9657b7304b940a6726b4c86213  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  11.8   opt  010826  eaca80bf3208fb9657b7304b940a6726b4c86213  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  12.3   dbg  010826  51263b851df7093758e98c7029f091332c1c576f  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  12.3   opt  010826  51263b851df7093758e98c7029f091332c1c576f  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  13.0   dbg  010826  1a4bb1bbfde5fa17ba148cb62678902f11c66a1a  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  13.0   opt  010826  1a4bb1bbfde5fa17ba148cb62678902f11c66a1a  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  13.1   dbg  010826  548c80aeafb6dd2be64f56e902e921a4052b5fe0  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      CS  13.1   opt  010826  548c80aeafb6dd2be64f56e902e921a4052b5fe0  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  10.6   dbg  010826  fcecb2620f25965723d640decede7c018bcb1dcc  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  10.6   opt  010826  fcecb2620f25965723d640decede7c018bcb1dcc  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  11.4   dbg  010826  3b34189bfe675c18c4ced3ef531d016ea74c76f4  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  11.4   opt  010826  3b34189bfe675c18c4ced3ef531d016ea74c76f4  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  11.8   dbg  010826  4694e931d10fecf733c34f83ea2146d31b708eb3  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  11.8   opt  010826  4694e931d10fecf733c34f83ea2146d31b708eb3  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  12.3   dbg  010826  c86ea989a715d9fbe1a5d760939acec22acfc0df  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      ES  12.3   opt  010826  c86ea989a715d9fbe1a5d760939acec22acfc0df  MSAN|use-of-uninitialized-value|sql/item_timefunc.cc|extract_date_time|Item_func_str_to_date::get_date_common|Type_handler_temporal_with_date::Item_update_null_value|Item_func::is_null
      

      Attachments

        Activity

          People

            raghunandan.bhat Raghunandan Bhat
            saahil Saahil Alam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0d
                0d
                Remaining:
                Time Spent - 1.5h Remaining Estimate - 1.5d
                1.5d
                Logged:
                Time Spent - 1.5h Remaining Estimate - 1.5d
                1.5h

                Git Integration

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