[MDEV-28718] bootstrap access to sys_var_slave_parallel_mode segfaults Created: 2022-06-01  Updated: 2022-07-18

Status: Open
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.6.8
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Daniel Black Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-28782 mariadb-tzinfo-to-sql to work in boot... Closed

 Description   

Triggered by select on information_schema.SYSTEM_VARIABLES.

$ gdb --args sql/mysqld --bootstrap --datadir=/tmp/datadir
...
(gdb) run
Starting program: /home/dan/repos/build-mariadb-server-10.6/sql/mysqld --bootstrap --datadir=/tmp/datadir
 
2022-06-01 12:27:12 0 [Note] InnoDB: Buffer pool(s) load completed at 220601 12:27:12
[New Thread 0x7ffff4396640 (LWP 38146)]
set @wsrep_is_on=(select sum(VARIABLE_NAME='wsrep_on' AND SESSION_VALUE='ON') from information_schema.SYSTEM_VARIABLES);
 
Thread 1 "mysqld" received signal SIGSEGV, Segmentation fault.
0x0000555556364bd7 in my_hash_first (hash=0x2f0, key=0x7fffffffc230 "", length=0, current_record=current_record@entry=0x7fffffffc21c) at /home/dan/repos/mariadb-server-10.6/mysys/hash.c:263
263	                                     hash->hash_function(hash->charset, key,
Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-11.fc36.x86_64 glibc-2.35-9.fc36.x86_64 libaio-0.3.111-13.fc36.x86_64 libcap-2.48-4.fc36.x86_64 libgcc-12.1.1-1.fc36.x86_64 libgcrypt-1.10.1-2.fc36.x86_64 libgpg-error-1.45-1.fc36.x86_64 libstdc++-12.1.1-1.fc36.x86_64 libxcrypt-4.4.28-1.fc36.x86_64 libzstd-1.5.2-2.fc36.x86_64 lz4-libs-1.9.3-4.fc36.x86_64 lzo-2.10-6.fc36.x86_64 numactl-libs-2.0.14-5.fc36.x86_64 openssl-libs-3.0.2-5.fc36.x86_64 pcre2-10.40-1.fc36.x86_64 snappy-1.1.9-4.fc36.x86_64 systemd-libs-250.6-1.fc36.x86_64 xz-libs-5.2.5-9.fc36.x86_64 zlib-1.2.11-31.fc36.x86_64
(gdb) p hash
$1 = (const HASH *) 0x2f0
(gdb) p *hash
Cannot access memory at address 0x2f0
(gdb) bt
#0  0x0000555556364bd7 in my_hash_first (hash=0x2f0, key=0x7fffffffc230 "", length=0, current_record=current_record@entry=0x7fffffffc21c)
    at /home/dan/repos/mariadb-server-10.6/mysys/hash.c:263
#1  0x0000555556364c21 in my_hash_search (hash=<optimized out>, key=<optimized out>, length=<optimized out>) at /home/dan/repos/mariadb-server-10.6/mysys/hash.c:235
#2  0x0000555555dd73e2 in Master_info_index::get_master_info (this=0x0, connection_name=connection_name@entry=0x5555579a93c8, warning=Sql_state_errno_level::WARN_LEVEL_ERROR)
    at /home/dan/repos/mariadb-server-10.6/sql/rpl_mi.cc:1367
#3  0x0000555555df0603 in Sys_var_slave_parallel_mode::global_value_ptr (this=0x555556c25240 <Sys_slave_parallel_mode>, thd=<optimized out>, base_name=0x5555579a93c8)
    at /home/dan/repos/mariadb-server-10.6/sql/sys_vars.cc:2342
#4  0x0000555555c305ab in sys_var::value_ptr (this=0x555556c25240 <Sys_slave_parallel_mode>, thd=0x5555579a8868, type=<optimized out>, base=0x55555641ece0 <null_clex_str>)
    at /home/dan/repos/mariadb-server-10.6/sql/set_var.cc:280
#5  0x0000555555c31ca6 in store_var (str=0x7fffffffc430, scope=SHOW_OPT_GLOBAL, var=0x555556c25240 <Sys_slave_parallel_mode>, field=0x5555579cd588)
    at /home/dan/repos/mariadb-server-10.6/sql/set_var.cc:1084
#6  store_var (str=0x7fffffffc430, scope=SHOW_OPT_GLOBAL, var=0x555556c25240 <Sys_slave_parallel_mode>, field=0x5555579cd588)
    at /home/dan/repos/mariadb-server-10.6/sql/set_var.cc:1078
#7  fill_sysvars (thd=<optimized out>, tables=<optimized out>, cond=<optimized out>) at /home/dan/repos/mariadb-server-10.6/sql/set_var.cc:1124
#8  0x0000555555d5f2b6 in get_schema_tables_result (join=join@entry=0x5555579cca68, executed_place=executed_place@entry=PROCESSED_BY_JOIN_EXEC)
    at /home/dan/repos/mariadb-server-10.6/sql/sql_show.cc:8878
#9  0x0000555555d4313d in JOIN::exec_inner (this=0x5555579cca68) at /home/dan/repos/mariadb-server-10.6/sql/sql_select.cc:4720
#10 0x0000555555d43b70 in JOIN::exec (this=0x5555579cca68) at /home/dan/repos/mariadb-server-10.6/sql/sql_select.cc:4541
#11 0x0000555555f988ce in subselect_single_select_engine::exec (this=0x5555579cc0f0) at /home/dan/repos/mariadb-server-10.6/sql/item_subselect.cc:4136
#12 0x0000555555f970bd in Item_subselect::exec (this=0x5555579cbf68) at /home/dan/repos/mariadb-server-10.6/sql/item_subselect.cc:854
#13 0x0000555555f97eaf in Item_singlerow_subselect::val_decimal (decimal_value=0x5555579cc220, this=0x5555579cbf68)
    at /home/dan/repos/mariadb-server-10.6/sql/item_subselect.cc:1561
#14 Item_singlerow_subselect::val_decimal (this=0x5555579cbf68, decimal_value=0x5555579cc220) at /home/dan/repos/mariadb-server-10.6/sql/item_subselect.cc:1552
#15 0x0000555555f56b4c in Item_func_set_user_var::check (this=0x5555579cc130, use_result_field=<optimized out>, use_result_field@entry=false)
    at /home/dan/repos/mariadb-server-10.6/sql/item_func.cc:5113
#16 0x0000555555c2f907 in set_var_user::check (this=0x5555579cc270, thd=<optimized out>) at /home/dan/repos/mariadb-server-10.6/sql/set_var.cc:900
#17 0x0000555555c316a5 in sql_set_variables (thd=thd@entry=0x5555579a8868, var_list=var_list@entry=0x5555579ad918, free=free@entry=true)
    at /home/dan/repos/mariadb-server-10.6/sql/set_var.cc:738
#18 0x0000555555ce0ccd in mysql_execute_command (thd=0x5555579a8868, is_called_from_prepared_stmt=<optimized out>) at /home/dan/repos/mariadb-server-10.6/sql/sql_parse.cc:5035
#19 0x0000555555ce2a45 in mysql_parse (thd=0x5555579a8868, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>)
    at /home/dan/repos/mariadb-server-10.6/sql/sql_parse.cc:8029
#20 0x0000555555ce2dee in bootstrap (file=0x5555574cf6b0 <instrumented_stdin>) at /home/dan/repos/mariadb-server-10.6/sql/sql_class.h:234
#21 0x0000555555c22376 in mysqld_main (argc=<optimized out>, argv=<optimized out>) at /home/dan/repos/mariadb-server-10.6/sql/mysqld.cc:5791
#22 0x00007ffff7352550 in __libc_start_call_main () from /lib64/libc.so.6
#23 0x00007ffff7352609 in __libc_start_main_impl () from /lib64/libc.so.6
#24 0x0000555555c16c85 in _start ()



 Comments   
Comment by Daniel Lenski [ 2022-06-01 ]

Thanks for opening this danblack.

I kicked this off by commenting on the commit because it turned out to fix a lot of other issues I had been puzzling over, in terms of being able to pipe the mariadb-tzinfo-to-sql output into | mysqld --bootstrap.

Comment by Daniel Lenski [ 2022-06-01 ]

Based on your comments and testing danblack

That's an extremely unexpected pattern which would be basically impossible to explain or find without a debugger.

This fits into a larger class of problems that otto and I have been discussing: the SQL parsing, execution, and error reporting of mysqld --bootstrap appears to be extremely limited and buggy compared to other environments.

Generated at Thu Feb 08 10:02:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.