Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.5, 10.6, 10.11, 11.4, 11.7(EOL), 11.8
Description
SET @@collation_connection=utf32_czech_ci; |
SELECT''LIKE''ESCAPE EXPORT_SET (1,1,1,1,''); |
Leads to:
CS 10.5.28 df602ff7fa5ed9424a1d7ebaba67b665e2f6d1f6 (Debug, UBASAN, Clang) Build 17/01/2025 |
/test/10.5_dbg_san/strings/ctype-utf32.h:27:9: runtime error: applying non-zero offset 4 to null pointer
|
#0 0x561deb715e90 in my_mb_wc_utf32_quick /test/10.5_dbg_san/strings/ctype-utf32.h:27:9
|
#1 0x561de9cdc78c in charset_info_st::mb_wc(unsigned long*, unsigned char const*, unsigned char const*) const /test/10.5_dbg_san/include/m_ctype.h:734:12
|
#2 0x561de9cdc78c in fix_escape_item(THD*, Item*, String*, bool, charset_info_st const*, int*) /test/10.5_dbg_san/sql/item_cmpfunc.cc:5892:21
|
#3 0x561de9cdd0e5 in Item_func_like::fix_fields(THD*, Item**) /test/10.5_dbg_san/sql/item_cmpfunc.cc:5932:7
|
#4 0x561de89fe16b in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /test/10.5_dbg_san/sql/item.h:1009:12
|
#5 0x561de8bcd069 in setup_fields(THD*, Bounds_checked_array<Item*>, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool) /test/10.5_dbg_san/sql/sql_base.cc:7673:15
|
#6 0x561de8f49a80 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /test/10.5_dbg_san/sql/sql_select.cc:1375:7
|
#7 0x561de8f3d549 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:4897:21
|
#8 0x561de8f3c3c2 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
|
#9 0x561de8e6b1e3 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6451:12
|
#10 0x561de8e53104 in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4043:12
|
#11 0x561de8e231c7 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8251:18
|
#12 0x561de8e17119 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
|
#13 0x561de8e2531e in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
|
#14 0x561de942da07 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
|
#15 0x561de942d2cb in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
|
#16 0x561de893803c in asan_thread_start(void*) asan_interceptors.cpp.o
|
#17 0x14b93f69ca93 in start_thread nptl/pthread_create.c:447:8
|
#18 0x14b93f729c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
|
|
SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /test/10.5_dbg_san/strings/ctype-utf32.h:27:9
|
Setup:
Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18. Ubuntu instructions:
|
# 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 following these steps
|
# 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++ -DCMAKE_C{,XX}_FLAGS='-march=native -mtune=native'" 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' in UBSAN_OPTIONS. For an example of UBSAN.filter, which includes current startup issues see: https://github.com/mariadb-corporation/mariadb-qa/blob/master/UBSAN.filter
|
export ASAN_OPTIONS=quarantine_size_mb=512:atexit=0:detect_invalid_pointer_pairs=3:dump_instruction_bytes=1:abort_on_error=1:allocator_may_return_null=1
|
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.2 (dbg), 11.7.2 (opt), 11.8.0 (dbg), 11.8.0 (opt)
Testcase is CLI and MTR compatible. Present in at least InnoDB+MyISAM
Additional testcase w/ offset stack
CS 10.5.28 df602ff7fa5ed9424a1d7ebaba67b665e2f6d1f6 (Debug, UBASAN, Clang) Build 17/01/2025
/test/10.5_dbg_san/strings/ctype-ucs2.h:25:8: runtime error: applying non-zero offset 2 to null pointer
#0 0x55c5c3d21fcc in my_mb_wc_ucs2_quick /test/10.5_dbg_san/strings/ctype-ucs2.h:25:8
#1 0x55c5c3d21fcc in my_ucs2_uni /test/10.5_dbg_san/strings/ctype-ucs2.c:3066:10
#2 0x55c5c22f378c in charset_info_st::mb_wc(unsigned long*, unsigned char const*, unsigned char const*) const /test/10.5_dbg_san/include/m_ctype.h:734:12
#3 0x55c5c22f378c in fix_escape_item(THD*, Item*, String*, bool, charset_info_st const*, int*) /test/10.5_dbg_san/sql/item_cmpfunc.cc:5892:21
#4 0x55c5c22f40e5 in Item_func_like::fix_fields(THD*, Item**) /test/10.5_dbg_san/sql/item_cmpfunc.cc:5932:7
#5 0x55c5c101516b in Item::fix_fields_if_needed_for_scalar(THD*, Item**) /test/10.5_dbg_san/sql/item.h:1009:12
#6 0x55c5c11e4069 in setup_fields(THD*, Bounds_checked_array<Item*>, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool) /test/10.5_dbg_san/sql/sql_base.cc:7673:15
#7 0x55c5c1560a80 in JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) /test/10.5_dbg_san/sql/sql_select.cc:1375:7
#8 0x55c5c1554549 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:4897:21
#9 0x55c5c15533c2 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
#10 0x55c5c14821e3 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6451:12
#11 0x55c5c146a104 in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4043:12
#12 0x55c5c143a1c7 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8251:18
#13 0x55c5c142e119 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
#14 0x55c5c143c31e in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
#15 0x55c5c1a44a07 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
#16 0x55c5c1a442cb in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
#17 0x55c5c0f4f03c in asan_thread_start(void*) asan_interceptors.cpp.o
#18 0x147ec409ca93 in start_thread nptl/pthread_create.c:447:8
#19 0x147ec4129c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /test/10.5_dbg_san/strings/ctype-ucs2.h:25:8