[MDEV-21791] Packed keys: connect.mysql_index crashes in BB on 32-bit box Created: 2020-02-20  Updated: 2020-03-13  Resolved: 2020-03-13

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Fix Version/s: 10.5.2

Type: Task Priority: Major
Reporter: Sergei Petrunia Assignee: Varun Gupta (Inactive)
Resolution: Duplicate Votes: 0
Labels: None

Attachments: File bug.sql    
Issue Links:
PartOf
is part of MDEV-21580 Allow packed sort keys in sort buffer Closed

 Description   

The crash is here:

http://buildbot.askmonty.org/buildbot/builders/kvm-bintar-quantal-x86/builds/21308/steps/mtr/logs/stdio

It's reproducible in the buildbot VM:

#1  0xb738daa2 in pthread_kill () from /lib/i386-linux-gnu/libpthread.so.0
#2  0xb80ff4a7 in my_write_core (sig=11) at /home/buildbot/10.5/mysys/stacktrace.c:518
#3  0xb7ab4b76 in handle_fatal_signal (sig=11) at /home/buildbot/10.5/sql/signal_handler.cc:343
#4  <signal handler called>
#5  read_addon_length (p=0x10b9850 <Address 0x10b9850 out of bounds>) at /home/buildbot/10.5/sql/sql_sort.h:223
#6  get_addon_length (plen=0x10b9850 <Address 0x10b9850 out of bounds>, this=0xb11fdeb0) at /home/buildbot/10.5/sql/sql_sort.h:431
#7  get_result_length (plen=0x10b9850 <Address 0x10b9850 out of bounds>, this=0xb11fdeb0) at /home/buildbot/10.5/sql/sql_sort.h:425
#8  read_to_buffer (fromfile=fromfile@entry=0xb11fdf14, buffpek=buffpek@entry=0xb1057e4c, param=param@entry=0xb11fdeb0) at /home/buildbot/10.5/sql/filesort.cc:1742
#9  0xb7ab15a1 in merge_buffers (param=param@entry=0xb11fdeb0, from_file=from_file@entry=0xb11fdf14, to_file=to_file@entry=0xb11fdd10, sort_buffer=..., lastbuff=lastbuff@entry=0xb1057c10, Fb=Fb@entry=0xb1057e20, Tb=Tb@entry=0xb1057f28, flag=flag@entry=0) at /home/buildbot/10.5/sql/filesort.cc:1882
#10 0xb7ab1fd9 in merge_many_buff (param=param@entry=0xb11fdeb0, sort_buffer=..., buffpek=buffpek@entry=0xb1057bb8, maxbuffer=maxbuffer@entry=0xb11fde78, t_file=t_file@entry=0xb11fdf14) at /home/buildbot/10.5/sql/filesort.cc:1664
#11 0xb7ab3da4 in filesort (thd=0xb1000508, table=0xb103e920, filesort=0xb100faf0, tracker=0xb100ff90, join=0xb100e7d0, first_table_bit=1) at /home/buildbot/10.5/sql/filesort.cc:383
#12 0xb78d671d in create_sort_index (thd=0xb1000508, join=0xb100e7d0, tab=tab@entry=0xb100f480, fsort=0xb100faf0, fsort@entry=0x0) at /home/buildbot/10.5/sql/sql_select.cc:23696
#13 0xb78d6ade in st_join_table::sort_table (this=this@entry=0xb100f480) at /home/buildbot/10.5/sql/sql_select.cc:21435
#14 0xb78d6b7a in join_init_read_record (tab=0xb100f480) at /home/buildbot/10.5/sql/sql_select.cc:21374
#15 0xb78c78c6 in sub_select (join=0xb100e7d0, join_tab=0xb100f480, end_of_records=false) at /home/buildbot/10.5/sql/sql_select.cc:20451
#16 0xb78eb3d6 in do_select (procedure=<optimized out>, join=0xb100e7d0) at /home/buildbot/10.5/sql/sql_select.cc:19992
#17 JOIN::exec_inner (this=this@entry=0xb100e7d0) at /home/buildbot/10.5/sql/sql_select.cc:4457
#18 0xb78eb699 in JOIN::exec (this=0xb100e7d0) at /home/buildbot/10.5/sql/sql_select.cc:4238
#19 0xb78e97dd in mysql_select (thd=thd@entry=0xb1000508, tables=0xb100dac8, fields=..., conds=0x0, og_num=2, order=0xb100e5c8, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=result@entry=0xb100e7b8, unit=unit@entry=0xb1002bd0, select_lex=select_lex@entry=0xb100d5a0) at /home/buildbot/10.5/sql/sql_select.cc:4662
#20 0xb78ea3ba in handle_select (thd=0xb1000508, lex=0xb1002b60, result=0xb100e7b8, setup_tables_done_option=0) at /home/buildbot/10.5/sql/sql_select.cc:428
#21 0xb7741bbf in execute_sqlcom_select (thd=thd@entry=0xb1000508, all_tables=0xb100dac8) at /home/buildbot/10.5/sql/sql_parse.cc:6138
#22 0xb788cfe7 in mysql_execute_command (thd=thd@entry=0xb1000508) at /home/buildbot/10.5/sql/sql_parse.cc:3904
#23 0xb789056b in mysql_parse (thd=thd@entry=0xb1000508, rawbuf=0xb100d4c8 "SELECT matricule, nom, prenom FROM t2 ORDER BY nom,prenom LIMIT 10", length=66, parser_state=0xb11feb6c, is_com_multi=false, is_next_command=false) at /home/buildbot/10.5/sql/sql_parse.cc:7918



 Comments   
Comment by Sergei Petrunia [ 2020-02-20 ]

git clone --branch bb-10.5-6915  --depth 1 https://github.com/MariaDB/server.git
cd server
cmake . -DCMAKE_BUILD_TYPE=Debug -DWITHOUT_MROONGA:bool=1 -DWITHOUT_TOKUDB:bool=1 && make -j10 
cd mysql-test/
./mysql-test-run connect.mysql_index

Comment by Roel Van de Paar [ 2020-03-02 ]

I am running into this also. Ref attached bug.sql. When executed as follows;

10.5.2> SOURCE bug.sql;

It leads to:

Core was generated by `/t/MD240220-mariadb-10.5.2-linux-x86_64-debug/bin/mysqld --no-defaults --plugin...'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
57      ../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
[Current thread is 1 (Thread 0x7f9ede4b9700 (LWP 20791))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055e5ae1a03a6 in my_write_core (sig=sig@entry=6) at /t/bb-10.5-6915_dbg/mysys/stacktrace.c:518
#2  0x000055e5ad984345 in handle_fatal_signal (sig=6) at /t/bb-10.5-6915_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007f9edc289801 in __GI_abort () at abort.c:79
#6  0x00007f9edc27939a in __assert_fail_base (fmt=0x7f9edc4007d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55e5ae40e710 "sort_length <= param->sort_length", 
    file=file@entry=0x55e5ae40e450 "/t/bb-10.5-6915_dbg/sql/filesort.cc", line=line@entry=1738, 
    function=function@entry=0x55e5ae40f280 <read_to_buffer(st_io_cache*, Merge_chunk*, Sort_param*)::__PRETTY_FUNCTION__> "ulong read_to_buffer(IO_CACHE*, Merge_chunk*, Sort_param*)") at assert.c:92
#7  0x00007f9edc279412 in __GI___assert_fail (assertion=assertion@entry=0x55e5ae40e710 "sort_length <= param->sort_length", file=file@entry=0x55e5ae40e450 "/t/bb-10.5-6915_dbg/sql/filesort.cc", line=line@entry=1738, 
    function=function@entry=0x55e5ae40f280 <read_to_buffer(st_io_cache*, Merge_chunk*, Sort_param*)::__PRETTY_FUNCTION__> "ulong read_to_buffer(IO_CACHE*, Merge_chunk*, Sort_param*)") at assert.c:101
#8  0x000055e5ad97d66d in read_to_buffer (fromfile=fromfile@entry=0x7f9ede4b6cc0, buffpek=buffpek@entry=0x7f9eafc6b460, param=param@entry=0x7f9ede4b6c20) at /t/bb-10.5-6915_dbg/sql/filesort.cc:1738
#9  0x000055e5ad97f83c in merge_buffers (param=param@entry=0x7f9ede4b6c20, from_file=from_file@entry=0x7f9ede4b6cc0, to_file=to_file@entry=0x7f9eafd70440, sort_buffer=..., lastbuff=lastbuff@entry=0x7f9eafc6b3f0, Fb=0x7f9eafc6b3f0, 
    Tb=0x7f9eafc6b4d0, flag=1) at /t/bb-10.5-6915_dbg/sql/filesort.cc:1886
#10 0x000055e5ad980856 in merge_index (param=param@entry=0x7f9ede4b6c20, sort_buffer=..., buffpek=buffpek@entry=0x7f9eafc6b3f0, maxbuffer=4, tempfile=tempfile@entry=0x7f9ede4b6cc0, outfile=0x7f9eafd70440)
    at /t/bb-10.5-6915_dbg/sql/filesort.cc:2112
#11 0x000055e5ad983142 in filesort (thd=thd@entry=0x7f9eafc15070, table=table@entry=0x7f9eafd78070, filesort=filesort@entry=0x7f9eafc75d40, tracker=0x7f9eafc76418, join=join@entry=0x7f9eafc73e28, first_table_bit=<optimized out>)
    at /t/bb-10.5-6915_dbg/sql/filesort.cc:389
#12 0x000055e5ad72327b in create_sort_index (thd=0x7f9eafc15070, join=0x7f9eafc73e28, tab=tab@entry=0x7f9eafc75230, fsort=0x7f9eafc75d40, fsort@entry=0x0) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:23696
#13 0x000055e5ad7235a2 in st_join_table::sort_table (this=this@entry=0x7f9eafc75230) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:21435
#14 0x000055e5ad7236d6 in join_init_read_record (tab=0x7f9eafc75230) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:21374
#15 0x000055e5ad7141e3 in sub_select (join=0x7f9eafc73e28, join_tab=0x7f9eafc75230, end_of_records=false) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:20451
#16 0x000055e5ad74b18d in do_select (procedure=0x0, join=0x7f9eafc73e28) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:19992
#17 JOIN::exec_inner (this=this@entry=0x7f9eafc73e28) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:4457
#18 0x000055e5ad74b789 in JOIN::exec (this=this@entry=0x7f9eafc73e28) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:4238
#19 0x000055e5ad749b68 in mysql_select (thd=thd@entry=0x7f9eafc15070, tables=<optimized out>, fields=..., conds=0x0, og_num=2, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f9eafc73e00, 
    unit=0x7f9eafc18fb8, select_lex=0x7f9eafc72178) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:4662
#20 0x000055e5ad749e90 in handle_select (thd=thd@entry=0x7f9eafc15070, lex=lex@entry=0x7f9eafc18ef8, result=result@entry=0x7f9eafc73e00, setup_tables_done_option=setup_tables_done_option@entry=0) at /t/bb-10.5-6915_dbg/sql/sql_select.cc:416
#21 0x000055e5ad6d54a0 in execute_sqlcom_select (thd=thd@entry=0x7f9eafc15070, all_tables=0x7f9eafc72a30) at /t/bb-10.5-6915_dbg/sql/sql_parse.cc:6138
#22 0x000055e5ad6ce118 in mysql_execute_command (thd=thd@entry=0x7f9eafc15070) at /t/bb-10.5-6915_dbg/sql/sql_parse.cc:3904
#23 0x000055e5ad6db4a4 in mysql_parse (thd=thd@entry=0x7f9eafc15070, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f9ede4b84c0, is_com_multi=is_com_multi@entry=false, 
    is_next_command=is_next_command@entry=false) at /t/bb-10.5-6915_dbg/sql/sql_parse.cc:7918
#24 0x000055e5ad6c7389 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f9eafc15070, packet=packet@entry=0x7f9eafc5f071 "", packet_length=packet_length@entry=66, is_com_multi=is_com_multi@entry=false, 
    is_next_command=is_next_command@entry=false) at /t/bb-10.5-6915_dbg/sql/sql_parse.cc:1844
#25 0x000055e5ad6c5bd3 in do_command (thd=0x7f9eafc15070) at /t/bb-10.5-6915_dbg/sql/sql_parse.cc:1363
#26 0x000055e5ad81d9ba in do_handle_one_connection (connect=<optimized out>, connect@entry=0x7f9eb5436d70, put_in_cache=put_in_cache@entry=true) at /t/bb-10.5-6915_dbg/sql/sql_connect.cc:1422
#27 0x000055e5ad81dd3a in handle_one_connection (arg=0x7f9eb5436d70) at /t/bb-10.5-6915_dbg/sql/sql_connect.cc:1319
#28 0x00007f9edcf6c6db in start_thread (arg=0x7f9ede4b9700) at pthread_create.c:463
#29 0x00007f9edc36a88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

The attached testcase is a reduced and stand-alone (does not require the txt file) form of the connect.mysql_index test.

Comment by Sergei Petrunia [ 2020-03-13 ]

Fixed as part of MDEV-21580

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