[MDEV-22640] SIGSEGV in Item_func_group_concat::add using JSON_ARRAYAGG (on optimized builds) Created: 2020-05-20  Updated: 2021-06-29  Resolved: 2020-06-04

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.5.4, 10.5.2, 10.5.3
Fix Version/s: 10.5.4

Type: Bug Priority: Critical
Reporter: Roel Van de Paar Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: affects-tests, not-10.1, not-10.2, not-10.3, not-10.4

Issue Links:
Relates
relates to MDEV-21915 Server crashes in copy_fields,Item_fu... Closed
relates to MDEV-22449 SIGSEGV in Item_func_group_concat::ad... Closed

 Description   

Looks like one missed codepath in MDEV-21915 bugfix.

USE test;
CREATE TABLE t(a INT,b INT) ENGINE=MEMORY;
INSERT INTO t SET a=1;
SELECT JSON_ARRAYAGG(b LIMIT 2) FROM t;

Leads to:

10.5.4 69077dea25f6e7cab4ff8927e4429ad62af9de49

Core was generated by `/test/MD160520-mariadb-10.5.4-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x15365ef9d700 (LWP 1642790))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x00005566c59b6617 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:518
#2  0x00005566c53790fa in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:329
#3  <signal handler called>
#4  0x00005566c543bbc4 in Item_func_group_concat::add (this=0x15363c047780, exclude_nulls=false) at /test/10.5_opt/sql/item_sum.cc:3999
#5  0x00005566c51ac148 in Item_sum::aggregator_add (this=0x15363c047780) at /test/10.5_opt/sql/item_sum.h:560
#6  Item_sum::reset_and_add (this=0x15363c047780) at /test/10.5_opt/sql/item_sum.h:445
#7  init_sum_functions (func_ptr=0x15363c049320, end_ptr=0x15363c049328) at /test/10.5_opt/sql/sql_select.cc:25660
#8  0x00005566c51d4c6c in end_send_group (join=0x15363c048c70, join_tab=<optimized out>, end_of_records=<optimized out>) at /test/10.5_opt/sql/sql_select.cc:22016
#9  0x00005566c51e1bf0 in do_select (procedure=<optimized out>, join=0x15363c048c70) at /test/10.5_opt/sql/sql_select.cc:20105
#10 JOIN::exec_inner (this=this@entry=0x15363c048c70) at /test/10.5_opt/sql/sql_select.cc:4464
#11 0x00005566c51e1e67 in JOIN::exec (this=this@entry=0x15363c048c70) at /test/10.5_opt/sql/sql_select.cc:4245
#12 0x00005566c51e01b2 in mysql_select (thd=thd@entry=0x15363c012018, tables=0x15363c047c68, fields=..., conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x15363c048c48, unit=0x15363c015e68, select_lex=0x15363c0470e0) at /test/10.5_opt/sql/sql_select.cc:4669
#13 0x00005566c51e0b71 in handle_select (thd=thd@entry=0x15363c012018, lex=lex@entry=0x15363c015da0, result=result@entry=0x15363c048c48, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_opt/sql/sql_select.cc:417
#14 0x00005566c5187781 in execute_sqlcom_select (thd=thd@entry=0x15363c012018, all_tables=0x15363c047c68) at /test/10.5_opt/sql/sql_parse.cc:6172
#15 0x00005566c51836a2 in mysql_execute_command (thd=thd@entry=0x15363c012018) at /test/10.5_opt/sql/sql_parse.cc:3901
#16 0x00005566c518a82c in mysql_parse (thd=0x15363c012018, rawbuf=<optimized out>, length=38, parser_state=0x15365ef9c4b0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7957
#17 0x00005566c517fe75 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x15363c012018, packet=packet@entry=0x15363c03a019 "", packet_length=packet_length@entry=38, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1839
#18 0x00005566c517e106 in do_command (thd=0x15363c012018) at /test/10.5_opt/sql/sql_parse.cc:1358
#19 0x00005566c5272bf1 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x15365cc329b8, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1411
#20 0x00005566c5272f54 in handle_one_connection (arg=arg@entry=0x15365cc329b8) at /test/10.5_opt/sql/sql_connect.cc:1313
#21 0x00005566c55de43a in pfs_spawn_thread (arg=0x15365cc4b018) at /test/10.5_opt/storage/perfschema/pfs.cc:2201
#22 0x000015365e3c46db in start_thread (arg=0x15365ef9d700) at pthread_create.c:463
#23 0x000015365d7c288f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.5.2 (dbg), 10.5.2 (opt), 10.5.3 (dbg), 10.5.3 (opt), 10.5.4 (dbg), 10.5.4 (opt)

Bug confirmed not present in:
MariaDB: 10.1.45 (dbg), 10.1.45 (opt), 10.2.32 (dbg), 10.2.32 (opt), 10.3.23 (dbg), 10.3.23 (opt), 10.4.13 (dbg), 10.4.13 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)



 Comments   
Comment by Alexey Botchkov [ 2020-06-04 ]

https://github.com/MariaDB/server/commit/bb47050e1fdc49aa56fb55c8c55ff81ba24d355b

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