[MDEV-17649] Server crashes after query with incorrect double values and window function Created: 2018-11-08  Updated: 2021-04-20  Resolved: 2021-04-20

Status: Closed
Project: MariaDB Server
Component/s: N/A
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Alice Sherepa
Resolution: Cannot Reproduce Votes: 0
Labels: None


 Description   

set sql_mode='';
 
CREATE TABLE t1 (pk int NOT NULL PRIMARY KEY, i1 int, KEY i1 (i1));
INSERT INTO t1 VALUES (1,7);
 
SELECT MIN(CAST(pk AS CHAR)) OVER () 
FROM t1
GROUP BY 'test' NOT BETWEEN 1 AND i1 WITH ROLLUP ;

10.2 3fbee66499624cf2340eaebcd230cbabf0dd97ee (built as -DCMAKE_BUILD_TYPE=Debug -DWITH_ASAN=ON)

Version: '10.2.19-MariaDB-debug-log'  socket: '/git/10.2/mysql-test/var/tmp/mysqld.1.sock'  port: 16000  Source distribution
=================================================================
==13991==ERROR: AddressSanitizer: unknown-crash on address 0x62b0000041d6 at pc 0x7f20e607edf8 bp 0x7f20cd8418d0 sp 0x7f20cd841078
READ of size 165 at 0x62b0000041d6 thread T27
    #0 0x7f20e607edf7 in __asan_memmove (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x8cdf7)
    #1 0x555acbe5c804 in String::copy(String const&) /git/10.2/sql/sql_string.cc:179
    #2 0x555acc2c67f7 in Item_cache_str::cache_value() /git/10.2/sql/item.cc:9936
    #3 0x555acc459e19 in Item_sum_min::add() /git/10.2/sql/item_sum.cc:2180
    #4 0x555acc0c217c in Frame_cursor::add_value_to_items() /git/10.2/sql/sql_window.cc:973
    #5 0x555acc0c6387 in Frame_scan_cursor::compute_values_for_current_row() /git/10.2/sql/sql_window.cc:2042
    #6 0x555acc0c6003 in Frame_scan_cursor::next_partition(unsigned long long) /git/10.2/sql/sql_window.cc:1999
    #7 0x555acc0c287d in Cursor_manager::notify_cursors_partition_changed(unsigned long long) /git/10.2/sql/sql_window.cc:1036
    #8 0x555acc0bdd92 in compute_window_func(THD*, List<Item_window_func>&, List<Cursor_manager>&, TABLE*, SORT_INFO*) /git/10.2/sql/sql_window.cc:2623
    #9 0x555acc0be4b4 in Window_func_runner::exec(THD*, TABLE*, SORT_INFO*) /git/10.2/sql/sql_window.cc:2742
    #10 0x555acc0be703 in Window_funcs_sort::exec(JOIN*, bool) /git/10.2/sql/sql_window.cc:2767
    #11 0x555acc0bf3ca in Window_funcs_computation::exec(JOIN*, bool) /git/10.2/sql/sql_window.cc:2893
    #12 0x555acbdd698b in AGGR_OP::end_send() /git/10.2/sql/sql_select.cc:26655
    #13 0x555acbd9f0ba in sub_select_postjoin_aggr(JOIN*, st_join_table*, bool) /git/10.2/sql/sql_select.cc:18465
    #14 0x555acbd9e4ce in do_select /git/10.2/sql/sql_select.cc:18296
    #15 0x555acbd40cf9 in JOIN::exec_inner() /git/10.2/sql/sql_select.cc:3609
    #16 0x555acbd3e9ff in JOIN::exec() /git/10.2/sql/sql_select.cc:3404
    #17 0x555acbd41d4c in mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /git/10.2/sql/sql_select.cc:3804
    #18 0x555acbd21722 in handle_select(THD*, LEX*, select_result*, unsigned long) /git/10.2/sql/sql_select.cc:376
    #19 0x555acbca84de in execute_sqlcom_select /git/10.2/sql/sql_parse.cc:6478
    #20 0x555acbc954d7 in mysql_execute_command(THD*) /git/10.2/sql/sql_parse.cc:3484
    #21 0x555acbcb0c42 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /git/10.2/sql/sql_parse.cc:8012
    #22 0x555acbc8c17b in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /git/10.2/sql/sql_parse.cc:1824
    #23 0x555acbc8932f in do_command(THD*) /git/10.2/sql/sql_parse.cc:1378
    #24 0x555acbfaebe7 in do_handle_one_connection(CONNECT*) /git/10.2/sql/sql_connect.cc:1335
    #25 0x555acbfae5ef in handle_one_connection /git/10.2/sql/sql_connect.cc:1241
    #26 0x555acd154337 in pfs_spawn_thread /git/10.2/storage/perfschema/pfs.cc:1862
    #27 0x7f20e4e2b6b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
    #28 0x7f20e42c041c in clone (/lib/x86_64-linux-gnu/libc.so.6+0x10741c)
 
0x62b0000041d6 is located 16342 bytes inside of 24716-byte region [0x62b000000200,0x62b00000628c)
allocated by thread T27 here:
    #0 0x7f20e608a602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x555acd26f77d in sf_malloc /git/10.2/mysys/safemalloc.c:118
    #2 0x555acd2400e1 in my_malloc /git/10.2/mysys/my_malloc.c:101
    #3 0x555acd221690 in reset_root_defaults /git/10.2/mysys/my_alloc.c:146
    #4 0x555acbbe46d1 in THD::init_for_queries() /git/10.2/sql/sql_class.cc:1306
    #5 0x555acbfadfb5 in prepare_new_connection_state(THD*) /git/10.2/sql/sql_connect.cc:1172
    #6 0x555acbfae635 in thd_prepare_connection(THD*) /git/10.2/sql/sql_connect.cc:1256
    #7 0x555acbfaebaf in do_handle_one_connection(CONNECT*) /git/10.2/sql/sql_connect.cc:1326
    #8 0x555acbfae5ef in handle_one_connection /git/10.2/sql/sql_connect.cc:1241
    #9 0x555acd154337 in pfs_spawn_thread /git/10.2/storage/perfschema/pfs.cc:1862
    #10 0x7f20e4e2b6b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
 
Thread T27 created by T0 here:
    #0 0x7f20e6028253 in pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x36253)
    #1 0x555acd154724 in spawn_thread_v1 /git/10.2/storage/perfschema/pfs.cc:1912
    #2 0x555acba991e6 in inline_mysql_thread_create /git/10.2/include/mysql/psi/mysql_thread.h:1239
    #3 0x555acbaad4ba in create_thread_to_handle_connection(CONNECT*) /git/10.2/sql/mysqld.cc:6466
    #4 0x555acbaadbba in create_new_thread /git/10.2/sql/mysqld.cc:6536
    #5 0x555acbaaebfd in handle_connections_sockets() /git/10.2/sql/mysqld.cc:6811
    #6 0x555acbaaca0a in mysqld_main(int, char**) /git/10.2/sql/mysqld.cc:6085
    #7 0x555acba97b7f in main /git/10.2/sql/main.cc:25
    #8 0x7f20e41d982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
 
SUMMARY: AddressSanitizer: unknown-crash ??:0 __asan_memmove
Shadow bytes around the buggy address:
  0x0c567fff87e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c567fff87f0: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 00
  0x0c567fff8800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c567fff8810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c567fff8820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c567fff8830: 00 00 00 00 00 00 00 00 00 00[06]00 00 00 00 00
  0x0c567fff8840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c567fff8850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c567fff8860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c567fff8870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c567fff8880: 00 00 00 00 00 00 00 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
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  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
==13991==ABORTING
----------SERVER LOG END-------------



 Comments   
Comment by Alice Sherepa [ 2021-04-20 ]

not reproducible on current 10.2-10.5

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