[MDEV-25261] Assertion `arg2_int >= 0' or Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision Created: 2021-03-26  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Data types, Server
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

CREATE TABLE t (d DECIMAL(65,32));
INSERT INTO t VALUES (1.1),(2.2); # Optional, fails either way
 
SELECT ROUND(d, CRC32(d)) + 1 FROM t;
 
# Cleanup
DROP TABLE t;

10.2 cdb86faf

mysqld: /data/src/10.2/sql/item_func.cc:1404: virtual void Item_func_additive_op::result_precision(): Assertion `arg1_int >= 0' failed.
210326  2:37:40 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f60d1f8cf36 in __GI___assert_fail (assertion=0x56181483fe97 "arg1_int >= 0", file=0x56181483f908 "/data/src/10.2/sql/item_func.cc", line=1404, function=0x56181483fe60 "virtual void Item_func_additive_op::result_precision()") at assert.c:101
#8  0x0000561813fe8f2d in Item_func_additive_op::result_precision (this=0x7f60bc012ca0) at /data/src/10.2/sql/item_func.cc:1404
#9  0x0000561813fe66f0 in Item_num_op::fix_length_and_dec (this=0x7f60bc012ca0) at /data/src/10.2/sql/item_func.cc:776
#10 0x0000561813fe4bba in Item_func::fix_fields (this=0x7f60bc012ca0, thd=0x7f60bc000d90, ref=0x7f60bc012d78) at /data/src/10.2/sql/item_func.cc:230
#11 0x0000561813c7e98d in setup_fields (thd=0x7f60bc000d90, ref_pointer_array=..., fields=..., mark_used_columns=MARK_COLUMNS_READ, sum_func_list=0x7f60bc013838, pre_fix=0x7f60bc005208, allow_sum_func=true) at /data/src/10.2/sql/sql_base.cc:7283
#12 0x0000561813d27399 in JOIN::prepare (this=0x7f60bc013518, tables_init=0x7f60bc012e00, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7f60bc0050c8, unit_arg=0x7f60bc004988) at /data/src/10.2/sql/sql_select.cc:798
#13 0x0000561813d31e4a in mysql_select (thd=0x7f60bc000d90, tables=0x7f60bc012e00, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f60bc0134f8, unit=0x7f60bc004988, select_lex=0x7f60bc0050c8) at /data/src/10.2/sql/sql_select.cc:3818
#14 0x0000561813d2605e in handle_select (thd=0x7f60bc000d90, lex=0x7f60bc0048c8, result=0x7f60bc0134f8, setup_tables_done_option=0) at /data/src/10.2/sql/sql_select.cc:361
#15 0x0000561813cf067f in execute_sqlcom_select (thd=0x7f60bc000d90, all_tables=0x7f60bc012e00) at /data/src/10.2/sql/sql_parse.cc:6274
#16 0x0000561813ce71f3 in mysql_execute_command (thd=0x7f60bc000d90) at /data/src/10.2/sql/sql_parse.cc:3585
#17 0x0000561813cf443b in mysql_parse (thd=0x7f60bc000d90, rawbuf=0x7f60bc0126f8 "SELECT ROUND(d, CRC32(d)) + 1 FROM t", length=36, parser_state=0x7f60cc0e75f0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7794
#18 0x0000561813ce2664 in dispatch_command (command=COM_QUERY, thd=0x7f60bc000d90, packet=0x7f60bc008b51 "SELECT ROUND(d, CRC32(d)) + 1 FROM t", packet_length=36, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1827
#19 0x0000561813ce115f in do_command (thd=0x7f60bc000d90) at /data/src/10.2/sql/sql_parse.cc:1381
#20 0x0000561813e3bc94 in do_handle_one_connection (connect=0x561816959110) at /data/src/10.2/sql/sql_connect.cc:1336
#21 0x0000561813e3b9f9 in handle_one_connection (arg=0x561816959110) at /data/src/10.2/sql/sql_connect.cc:1241
#22 0x0000561814664d10 in pfs_spawn_thread (arg=0x56181693c580) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#23 0x00007f60d249e609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#24 0x00007f60d2078293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

CREATE TABLE t (d DECIMAL(65,32));
INSERT INTO t VALUES (1.1),(2.2); # Optional, fails either way
 
SELECT 1 + ROUND(d, CRC32(d)) FROM t;
 
# Cleanup
DROP TABLE t;

mysqld: /data/src/10.2/sql/item_func.cc:1405: virtual void Item_func_additive_op::result_precision(): Assertion `arg2_int >= 0' failed.
210326  2:38:16 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fc2873faf36 in __GI___assert_fail (assertion=0x55d777f70ea5 "arg2_int >= 0", file=0x55d777f70908 "/data/src/10.2/sql/item_func.cc", line=1405, function=0x55d777f70e60 "virtual void Item_func_additive_op::result_precision()") at assert.c:101
#8  0x000055d777719f52 in Item_func_additive_op::result_precision (this=0x7fc270012ca0) at /data/src/10.2/sql/item_func.cc:1405
#9  0x000055d7777176f0 in Item_num_op::fix_length_and_dec (this=0x7fc270012ca0) at /data/src/10.2/sql/item_func.cc:776
#10 0x000055d777715bba in Item_func::fix_fields (this=0x7fc270012ca0, thd=0x7fc270000d90, ref=0x7fc270012d78) at /data/src/10.2/sql/item_func.cc:230
#11 0x000055d7773af98d in setup_fields (thd=0x7fc270000d90, ref_pointer_array=..., fields=..., mark_used_columns=MARK_COLUMNS_READ, sum_func_list=0x7fc270013838, pre_fix=0x7fc270005208, allow_sum_func=true) at /data/src/10.2/sql/sql_base.cc:7283
#12 0x000055d777458399 in JOIN::prepare (this=0x7fc270013518, tables_init=0x7fc270012e00, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fc2700050c8, unit_arg=0x7fc270004988) at /data/src/10.2/sql/sql_select.cc:798
#13 0x000055d777462e4a in mysql_select (thd=0x7fc270000d90, tables=0x7fc270012e00, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fc2700134f8, unit=0x7fc270004988, select_lex=0x7fc2700050c8) at /data/src/10.2/sql/sql_select.cc:3818
#14 0x000055d77745705e in handle_select (thd=0x7fc270000d90, lex=0x7fc2700048c8, result=0x7fc2700134f8, setup_tables_done_option=0) at /data/src/10.2/sql/sql_select.cc:361
#15 0x000055d77742167f in execute_sqlcom_select (thd=0x7fc270000d90, all_tables=0x7fc270012e00) at /data/src/10.2/sql/sql_parse.cc:6274
#16 0x000055d7774181f3 in mysql_execute_command (thd=0x7fc270000d90) at /data/src/10.2/sql/sql_parse.cc:3585
#17 0x000055d77742543b in mysql_parse (thd=0x7fc270000d90, rawbuf=0x7fc2700126f8 "SELECT 1 + ROUND(d, CRC32(d)) FROM t", length=36, parser_state=0x7fc2815555f0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7794
#18 0x000055d777413664 in dispatch_command (command=COM_QUERY, thd=0x7fc270000d90, packet=0x7fc270008b51 "SELECT 1 + ROUND(d, CRC32(d)) FROM t", packet_length=36, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1827
#19 0x000055d77741215f in do_command (thd=0x7fc270000d90) at /data/src/10.2/sql/sql_parse.cc:1381
#20 0x000055d77756cc94 in do_handle_one_connection (connect=0x55d77a030110) at /data/src/10.2/sql/sql_connect.cc:1336
#21 0x000055d77756c9f9 in handle_one_connection (arg=0x55d77a030110) at /data/src/10.2/sql/sql_connect.cc:1241
#22 0x000055d777d95d10 in pfs_spawn_thread (arg=0x55d77a013580) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#23 0x00007fc28790c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#24 0x00007fc2874e6293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on 10.2-10.6, with at least MyISAM and InnoDB.
No obvious problem on a non-debug build.



 Comments   
Comment by Alice Sherepa [ 2022-01-27 ]

mysqld: /10.8/sql/item_func.cc:1214: virtual void Item_func_additive_op::result_precision(): Assertion `arg2_int >= 0' failed.
220124 17:34:19 [ERROR] mysqld got signal 6 ;
 
linux/raise.c:51(__GI_raise)[0x7fae338787bb]
stdlib/abort.c:81(__GI_abort)[0x7fae33863535]
??:0(__assert_fail)[0x7fae33871102]
sql/item_func.cc:1217(Item_func_additive_op::result_precision())[0x56216dbe6684]
sql/item_func.h:1118(Item_num_op::fix_length_and_dec_decimal())[0x56216d879add]
sql/item_func.h:1574(Item_func_minus::fix_length_and_dec_decimal())[0x56216d87ada4]
sql/sql_type.cc:6866(Type_handler_decimal_result::Item_func_minus_fix_length_and_dec(Item_func_minus*) const)[0x56216d853124]
sql/item_func.cc:1245(Item_func_minus::fix_length_and_dec())[0x56216dbe6ba4]
sql/item_func.cc:359(Item_func::fix_fields(THD*, Item**))[0x56216dbde4bc]
sql/item.h:1145(Item::fix_fields_if_needed(THD*, Item**))[0x56216cf58729]
sql/item_func.cc:347(Item_func::fix_fields(THD*, Item**))[0x56216dbde206]
sql/item.h:1145(Item::fix_fields_if_needed(THD*, Item**))[0x56216cf58729]
sql/item_func.cc:347(Item_func::fix_fields(THD*, Item**))[0x56216dbde206]
sql/item.h:1145(Item::fix_fields_if_needed(THD*, Item**))[0x56216cf58729]
sql/item_func.cc:347(Item_func::fix_fields(THD*, Item**))[0x56216dbde206]
sql/item.h:1145(Item::fix_fields_if_needed(THD*, Item**))[0x56216cf58729]
sql/item_func.cc:347(Item_func::fix_fields(THD*, Item**))[0x56216dbde206]
sql/item_strfunc.cc:127(Item_str_func::fix_fields(THD*, Item**))[0x56216dc6e83d]
sql/item.h:1145(Item::fix_fields_if_needed(THD*, Item**))[0x56216cf58729]
sql/item.h:1148(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x56216cf58757]
sql/sql_base.cc:7718(setup_fields(THD*, Bounds_checked_array<Item*>, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool))[0x56216d0779e2]
sql/sql_select.cc:1397(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x56216d2f0954]
sql/sql_select.cc:4968(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*))[0x56216d316c32]
sql/sql_select.cc:545(handle_select(THD*, LEX*, select_result*, unsigned long))[0x56216d2e7a0f]
sql/sql_parse.cc:6252(execute_sqlcom_select(THD*, TABLE_LIST*))[0x56216d213edf]
sql/sql_parse.cc:3943(mysql_execute_command(THD*, bool))[0x56216d202a0f]
sql/sql_parse.cc:8027(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x56216d21ecbc]
sql/sql_parse.cc:1896(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x56216d1f5539]
sql/sql_parse.cc:1402(do_command(THD*, bool))[0x56216d1f222e]
sql/sql_connect.cc:1418(do_handle_one_connection(CONNECT*, bool))[0x56216d682220]
sql/sql_connect.cc:1314(handle_one_connection)[0x56216d681aa5]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x56216e30009a]
nptl/pthread_create.c:487(start_thread)[0x7fae33d2ffa3]
x86_64/clone.S:97(clone)[0x7fae3393a4cf]

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