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

UBSAN: runtime error: load of value 1341112147, which is not a valid value for type 'enum enum_schema_tables' in optimize_for_get_all_tables and get_all_tables and on SELECT from I_S geometry_columns

Details

    Description

      SELECT * FROM information_schema.geometry_columns;
      

      Leads to:

      CS 10.5.28 a226f12675c6312ca7632b90261397e313e6a7ae (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/sql/sql_show.cc:8728:52: runtime error: load of value 1341112147, which is not a valid value for type 'enum enum_schema_tables'
          #0 0x55abfc5d9b22 in optimize_for_get_all_tables(THD*, TABLE_LIST*, Item*) /test/10.5_dbg_san/sql/sql_show.cc:8728:52
          #1 0x55abfc5d95a4 in optimize_schema_tables_reads(JOIN*) /test/10.5_dbg_san/sql/sql_show.cc:8892:11
          #2 0x55abfc16078e in JOIN::optimize_stage2() /test/10.5_dbg_san/sql/sql_select.cc:2958:8
          #3 0x55abfc17597c in JOIN::optimize_inner() /test/10.5_dbg_san/sql/sql_select.cc:2445:9
          #4 0x55abfc151ffd in JOIN::optimize() /test/10.5_dbg_san/sql/sql_select.cc:1765:10
          #5 0x55abfc1029ab 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:4907:19
          #6 0x55abfc0ff097 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
          #7 0x55abfbeda580 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6451:12
          #8 0x55abfbe6e72f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4043:12
          #9 0x55abfbe15673 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8251:18
          #10 0x55abfbdf4863 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #11 0x55abfbe1dba9 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #12 0x55abfcd9a0c0 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #13 0x55abfcd9888d in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #14 0x55abfb291a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #15 0x14758ae9ca93 in start_thread nptl/pthread_create.c:447:8
          #16 0x14758af29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      CS 10.5.28 a226f12675c6312ca7632b90261397e313e6a7ae (Debug, UBASAN, Clang)

      SUMMARY: UndefinedBehaviorSanitizer: invalid-enum-load /test/10.5_dbg_san/sql/sql_show.cc:8728:52 
      /test/10.5_dbg_san/sql/sql_show.cc:5305:15: runtime error: load of value 1341112147, which is not a valid value for type 'enum enum_schema_tables'
          #0 0x55abfc5697cc in get_all_tables(THD*, TABLE_LIST*, Item*) /test/10.5_dbg_san/sql/sql_show.cc:5305:15
          #1 0x55abfc5df16a in get_schema_tables_result(JOIN*, enum_schema_table_state) /test/10.5_dbg_san/sql/sql_show.cc:9011:11
          #2 0x55abfc25afa9 in JOIN::exec_inner() /test/10.5_dbg_san/sql/sql_select.cc:4621:7
          #3 0x55abfc254c91 in JOIN::exec() /test/10.5_dbg_san/sql/sql_select.cc:4444:3
          #4 0x55abfc103513 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:4921:9
          #5 0x55abfc0ff097 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
          #6 0x55abfbeda580 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6451:12
          #7 0x55abfbe6e72f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4043:12
          #8 0x55abfbe15673 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8251:18
          #9 0x55abfbdf4863 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #10 0x55abfbe1dba9 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #11 0x55abfcd9a0c0 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #12 0x55abfcd9888d in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #13 0x55abfb291a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #14 0x14758ae9ca93 in start_thread nptl/pthread_create.c:447:8
          #15 0x14758af29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      CS 10.5.28 a226f12675c6312ca7632b90261397e313e6a7ae (Debug, UBASAN, Clang)

      SUMMARY: UndefinedBehaviorSanitizer: invalid-enum-load /test/10.5_dbg_san/sql/sql_show.cc:5305:15 
      /test/10.5_dbg_san/sql/sql_show.cc:5310:20: runtime error: load of value 1341112147, which is not a valid value for type 'enum enum_schema_tables'
          #0 0x55abfc5698b8 in get_all_tables(THD*, TABLE_LIST*, Item*) /test/10.5_dbg_san/sql/sql_show.cc:5310:20
          #1 0x55abfc5df16a in get_schema_tables_result(JOIN*, enum_schema_table_state) /test/10.5_dbg_san/sql/sql_show.cc:9011:11
          #2 0x55abfc25afa9 in JOIN::exec_inner() /test/10.5_dbg_san/sql/sql_select.cc:4621:7
          #3 0x55abfc254c91 in JOIN::exec() /test/10.5_dbg_san/sql/sql_select.cc:4444:3
          #4 0x55abfc103513 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:4921:9
          #5 0x55abfc0ff097 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
          #6 0x55abfbeda580 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6451:12
          #7 0x55abfbe6e72f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4043:12
          #8 0x55abfbe15673 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8251:18
          #9 0x55abfbdf4863 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #10 0x55abfbe1dba9 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #11 0x55abfcd9a0c0 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #12 0x55abfcd9888d in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #13 0x55abfb291a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #14 0x14758ae9ca93 in start_thread nptl/pthread_create.c:447:8
          #15 0x14758af29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: invalid-enum-load /test/10.5_dbg_san/sql/sql_show.cc:5310:20
      

      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

          Later versions like 11.8 may show more stacks (4 instead of 3), though the stacks match the ones already shown above.
          Note also that stack 2 and 3 above, while both show in the error log, are also the same.

          Roel Roel Van de Paar added a comment - Later versions like 11.8 may show more stacks (4 instead of 3), though the stacks match the ones already shown above. Note also that stack 2 and 3 above, while both show in the error log, are also the same.

          People

            holyfoot Alexey Botchkov
            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.