[MDEV-26494] main.mysqlcheck fails on ARM with ASAN use-after-poison in my_mb_wc_filename Created: 2021-08-29  Updated: 2023-10-18  Resolved: 2023-10-18

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.4.32, 10.5.23, 10.6.16, 10.10.7, 10.11.6, 11.0.4, 11.1.3

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None


 Description   

build on ARM

cmake -DPLUGIN_CONNECT=NO -DPLUGIN_COLUMNSTORE=NO -DPLUGIN_MROONGA=NO -DPLUGIN_XPAND=NO -DPLUGIN_TOKUDB=NO -DWITH_SSL=bundled -DMYSQL_MAINTAINER_MODE=OFF -DWITH_ASAN=YES -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-fno-omit-frame-pointer -DCMAKE_CXX_FLAGS=-fno-omit-frame-pointer -DWITH_PCRE=bundled

perl ./mtr main.mysqlcheck

10.6 7271cf48d6

==22713==ERROR: AddressSanitizer: use-after-poison on address 0xffff6f7324ac at pc 0xaaaab014af4c bp 0xffff6d6f8870 sp 0xffff6d6f8890
READ of size 1 at 0xffff6f7324ac thread T13
    #0 0xaaaab014af48 in my_mb_wc_filename /home/buildbot/10.6/strings/ctype-utf8.c:6968
    #1 0xaaaaae3fc948 in strconvert(charset_info_st const*, char const*, unsigned long, charset_info_st const*, char*, unsigned long, unsigned int*) /home/buildbot/10.6/sql/strfunc.cc:288
    #2 0xaaaaae3149c0 in filename_to_tablename(char const*, char*, unsigned long, bool) /home/buildbot/10.6/sql/sql_table.cc:398
    #3 0xaaaaae9713a4 in Discovered_table_list::add_file(char const*) /home/buildbot/10.6/sql/handler.cc:6387
    #4 0xaaaaae260490 in find_files /home/buildbot/10.6/sql/sql_show.cc:980
    #5 0xaaaaae278a6c in make_db_list /home/buildbot/10.6/sql/sql_show.cc:4368
    #6 0xaaaaae27d1f4 in get_all_tables(THD*, TABLE_LIST*, Item*) /home/buildbot/10.6/sql/sql_show.cc:5219
    #7 0xaaaaae2af4b0 in get_schema_tables_result(JOIN*, enum_schema_table_state) /home/buildbot/10.6/sql/sql_show.cc:8837
    #8 0xaaaaae17b788 in JOIN::exec_inner() /home/buildbot/10.6/sql/sql_select.cc:4694
    #9 0xaaaaae17961c in JOIN::exec() /home/buildbot/10.6/sql/sql_select.cc:4515
    #10 0xaaaaae17d91c 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*) /home/buildbot/10.6/sql/sql_select.cc:4993
    #11 0xaaaaae14e8f4 in handle_select(THD*, LEX*, select_result*, unsigned long) /home/buildbot/10.6/sql/sql_select.cc:545
    #12 0xaaaaae0a9110 in execute_sqlcom_select /home/buildbot/10.6/sql/sql_parse.cc:6256
    #13 0xaaaaae0972dc in mysql_execute_command(THD*, bool) /home/buildbot/10.6/sql/sql_parse.cc:3946
    #14 0xaaaaae0b403c in mysql_parse(THD*, char*, unsigned int, Parser_state*) /home/buildbot/10.6/sql/sql_parse.cc:8030
    #15 0xaaaaae0893c0 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /home/buildbot/10.6/sql/sql_parse.cc:1896
    #16 0xaaaaae085e9c in do_command(THD*, bool) /home/buildbot/10.6/sql/sql_parse.cc:1404
    #17 0xaaaaae5174e0 in do_handle_one_connection(CONNECT*, bool) /home/buildbot/10.6/sql/sql_connect.cc:1418
    #18 0xaaaaae516cf4 in handle_one_connection /home/buildbot/10.6/sql/sql_connect.cc:1312
    #19 0xaaaaaf339400 in pfs_spawn_thread /home/buildbot/10.6/storage/perfschema/pfs.cc:2201
    #20 0xffff82ace4f8 in start_thread (/lib/aarch64-linux-gnu/libpthread.so.0+0x84f8)
    #21 0xffff8275e678  (/lib/aarch64-linux-gnu/libc.so.6+0xd4678)
 
0xffff6f7324ac is located 172 bytes inside of 32932-byte region [0xffff6f732400,0xffff6f73a4a4)
allocated by thread T13 here:
    #0 0xffff82daaa30 in __interceptor_malloc (/lib/aarch64-linux-gnu/libasan.so.5+0xeda30)
    #1 0xaaaab006ddf0 in sf_malloc /home/buildbot/10.6/mysys/safemalloc.c:126
    #2 0xaaaab0034448 in my_malloc /home/buildbot/10.6/mysys/my_malloc.c:90
    #3 0xaaaab000663c in init_alloc_root /home/buildbot/10.6/mysys/my_alloc.c:81
    #4 0xaaaab0032378 in my_dir /home/buildbot/10.6/mysys/my_lib.c:140
    #5 0xaaaaae26016c in find_files /home/buildbot/10.6/sql/sql_show.cc:944
    #6 0xaaaaae278a6c in make_db_list /home/buildbot/10.6/sql/sql_show.cc:4368
    #7 0xaaaaae27d1f4 in get_all_tables(THD*, TABLE_LIST*, Item*) /home/buildbot/10.6/sql/sql_show.cc:5219
    #8 0xaaaaae2af4b0 in get_schema_tables_result(JOIN*, enum_schema_table_state) /home/buildbot/10.6/sql/sql_show.cc:8837
    #9 0xaaaaae17b788 in JOIN::exec_inner() /home/buildbot/10.6/sql/sql_select.cc:4694
    #10 0xaaaaae17961c in JOIN::exec() /home/buildbot/10.6/sql/sql_select.cc:4515
    #11 0xaaaaae17d91c 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*) /home/buildbot/10.6/sql/sql_select.cc:4993
    #12 0xaaaaae14e8f4 in handle_select(THD*, LEX*, select_result*, unsigned long) /home/buildbot/10.6/sql/sql_select.cc:545
    #13 0xaaaaae0a9110 in execute_sqlcom_select /home/buildbot/10.6/sql/sql_parse.cc:6256
    #14 0xaaaaae0972dc in mysql_execute_command(THD*, bool) /home/buildbot/10.6/sql/sql_parse.cc:3946
    #15 0xaaaaae0b403c in mysql_parse(THD*, char*, unsigned int, Parser_state*) /home/buildbot/10.6/sql/sql_parse.cc:8030
    #16 0xaaaaae0893c0 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /home/buildbot/10.6/sql/sql_parse.cc:1896
    #17 0xaaaaae085e9c in do_command(THD*, bool) /home/buildbot/10.6/sql/sql_parse.cc:1404
    #18 0xaaaaae5174e0 in do_handle_one_connection(CONNECT*, bool) /home/buildbot/10.6/sql/sql_connect.cc:1418
    #19 0xaaaaae516cf4 in handle_one_connection /home/buildbot/10.6/sql/sql_connect.cc:1312
    #20 0xaaaaaf339400 in pfs_spawn_thread /home/buildbot/10.6/storage/perfschema/pfs.cc:2201
    #21 0xffff82ace4f8 in start_thread (/lib/aarch64-linux-gnu/libpthread.so.0+0x84f8)
    #22 0xffff8275e678  (/lib/aarch64-linux-gnu/libc.so.6+0xd4678)
 
Thread T13 created by T0 here:
    #0 0xffff82cfaa9c in pthread_create (/lib/aarch64-linux-gnu/libasan.so.5+0x3da9c)
    #1 0xaaaaaf333ba0 in my_thread_create /home/buildbot/10.6/storage/perfschema/my_thread.h:48
    #2 0xaaaaaf339868 in pfs_spawn_thread_v1 /home/buildbot/10.6/storage/perfschema/pfs.cc:2252
    #3 0xaaaaadd4a278 in inline_mysql_thread_create /home/buildbot/10.6/include/mysql/psi/mysql_thread.h:1139
    #4 0xaaaaadd62fa4 in create_thread_to_handle_connection(CONNECT*) /home/buildbot/10.6/sql/mysqld.cc:5922
    #5 0xaaaaadd635cc in create_new_thread(CONNECT*) /home/buildbot/10.6/sql/mysqld.cc:5981
    #6 0xaaaaadd63960 in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /home/buildbot/10.6/sql/mysqld.cc:6043
    #7 0xaaaaadd64348 in handle_connections_sockets() /home/buildbot/10.6/sql/mysqld.cc:6167
    #8 0xaaaaadd6279c in mysqld_main(int, char**) /home/buildbot/10.6/sql/mysqld.cc:5817
    #9 0xaaaaadd494b4 in main /home/buildbot/10.6/sql/main.cc:34
    #10 0xffff826ae08c in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x2408c)
    #11 0xaaaaadd493c4  (/home/buildbot/10.6/sql/mariadbd+0x17e23c4)
 
SUMMARY: AddressSanitizer: use-after-poison /home/buildbot/10.6/strings/ctype-utf8.c:6968 in my_mb_wc_filename
Shadow bytes around the buggy address:
  0x200fedee6440: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x200fedee6450: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x200fedee6460: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x200fedee6470: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x200fedee6480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x200fedee6490: 00 00 00 00 f7[04]f7 00 00 00 00 00 00 00 00 00
  0x200fedee64a0: 00 00 00 00 00 00 00 f7 00 00 02 f7 00 00 00 00
  0x200fedee64b0: 00 00 00 00 00 00 00 00 00 00 00 00 f7 00 00 01
  0x200fedee64c0: f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200fedee64d0: 00 f7 07 f7 00 00 00 00 00 00 00 00 00 00 00 00
  0x200fedee64e0: 00 00 00 00 f7 06 f7 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==22713==ABORTING
210829 12:31:44 [ERROR] mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.
 
Server version: 10.6.5-MariaDB-debug-log
key_buffer_size=1048576
read_buffer_size=131072
max_used_connections=2
max_threads=153
thread_count=2
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 63872 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0xffff7338c288
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0xffff6d6fc7c0 thread_stack 0x100000
??:0(clock_getres)[0xffff82d260e8]
mysys/stacktrace.c:212(my_print_stacktrace)[0xaaaab0049264]
sql/signal_handler.cc:225(handle_fatal_signal)[0xaaaaae936ef8]
addr2line: 'linux-vdso.so.1': No such file
linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffff837e95b0]
??:0(gsignal)[0xffff826c1138]
??:0(abort)[0xffff826add68]
??:0(__sanitizer_set_report_fd)[0xffff82dc81e0]
??:0(__sanitizer_get_module_and_offset_for_pc)[0xffff82dd29e8]
??:0(__sanitizer_ptr_cmp)[0xffff82db3fc4]
??:0(__asan_on_error)[0xffff82db3a18]
??:0(__asan_report_load1)[0xffff82db45a0]
strings/ctype-utf8.c:6968(my_mb_wc_filename)[0xaaaab014af4c]
sql/strfunc.cc:288(strconvert(charset_info_st const*, char const*, unsigned long, charset_info_st const*, char*, unsigned long, unsigned int*))[0xaaaaae3fc94c]
sql/sql_table.cc:398(filename_to_tablename(char const*, char*, unsigned long, bool))[0xaaaaae3149c4]
sql/handler.cc:6387(Discovered_table_list::add_file(char const*))[0xaaaaae9713a8]
sql/sql_show.cc:980(find_files(THD*, Dynamic_array<st_mysql_const_lex_string*>*, st_mysql_const_lex_string*, char const*, st_mysql_const_lex_string const*))[0xaaaaae260494]
sql/sql_show.cc:4369(make_db_list(THD*, Dynamic_array<st_mysql_const_lex_string*>*, st_lookup_field_values*))[0xaaaaae278a70]
sql/sql_show.cc:5219(get_all_tables(THD*, TABLE_LIST*, Item*))[0xaaaaae27d1f8]
sql/sql_show.cc:8837(get_schema_tables_result(JOIN*, enum_schema_table_state))[0xaaaaae2af4b4]
sql/sql_select.cc:4694(JOIN::exec_inner())[0xaaaaae17b78c]
sql/sql_select.cc:4516(JOIN::exec())[0xaaaaae179620]
sql/sql_select.cc:4995(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*))[0xaaaaae17d920]
sql/sql_select.cc:545(handle_select(THD*, LEX*, select_result*, unsigned long))[0xaaaaae14e8f8]
sql/sql_parse.cc:6256(execute_sqlcom_select(THD*, TABLE_LIST*))[0xaaaaae0a9114]
sql/sql_parse.cc:3946(mysql_execute_command(THD*, bool))[0xaaaaae0972e0]
sql/sql_parse.cc:8030(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0xaaaaae0b4040]
sql/sql_parse.cc:1898(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0xaaaaae0893c4]
sql/sql_parse.cc:1404(do_command(THD*, bool))[0xaaaaae085ea0]
sql/sql_connect.cc:1418(do_handle_one_connection(CONNECT*, bool))[0xaaaaae5174e4]
sql/sql_connect.cc:1314(handle_one_connection)[0xaaaaae516cf8]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0xaaaaaf339404]
??:0(start_thread)[0xffff82ace4fc]
??:0(clone)[0xffff8275e67c]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0xffff733932a8): SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name
 
Connection ID (thread ID): 4
Status: NOT_KILLED
 
Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off
 
The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file...
Working directory at /dev/shm/var_auto_kCEo/mysqld.1/data
Resource Limits:
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    0                    bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             15222                15222                processes 
Max open files            1024                 1024                 files     
Max locked memory         67108864             67108864             bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       15222                15222                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        
Core pattern: |/usr/share/apport/apport %p %s %c %d %P %E

Reproducible on all ARMs that I tried, different Linux versions and compilers.
Couldn't reproduce on x86_64.



 Comments   
Comment by Daniel Black [ 2023-10-18 ]

Fixed thanks to xiaoniu.

Much appreciated.

Generated at Thu Feb 08 09:45:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.