[MDEV-26953] Assertion `!str || str != Ptr || !is_alloced()' failed in String::copy upon SELECT with sjis Created: 2021-11-01  Updated: 2023-07-20  Resolved: 2022-01-27

Status: Closed
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.4.23, 10.5.14, 10.6.6, 10.7.2, 10.8.1

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by MDEV-22856 Assertion `!str || str != Ptr' and As... Closed

 Description   

The fix for MDEV-25402 is already in the branches

SET NAMES sjis;
 
CREATE TABLE t (a VARCHAR(3));
INSERT INTO t VALUES (''),('');
SELECT GROUP_CONCAT(PASSWORD(a)) AS f FROM t;
 
# Cleanup
DROP TABLE t;

10.4 d352bc5b

mysqld: /data/src/10.4/sql/sql_string.cc:441: bool String::copy(const char*, size_t, CHARSET_INFO*, CHARSET_INFO*, uint*): Assertion `!str || str != Ptr || !is_alloced()' failed.
211101 19:13:51 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f5613857f36 in __GI___assert_fail (assertion=0x55e54ba33c28 "!str || str != Ptr || !is_alloced()", file=0x55e54ba33998 "/data/src/10.4/sql/sql_string.cc", line=441, function=0x55e54ba33c50 "bool String::copy(const char*, size_t, CHARSET_INFO*, CHARSET_INFO*, uint*)") at assert.c:101
#8  0x000055e54addb7ea in String::copy (this=0x7f55fc014e20, str=0x7f55fc0f3010 "", arg_length=0, from_cs=0x55e54c398b20 <my_charset_latin1>, to_cs=0x55e54c3dc7a0 <my_charset_sjis_japanese_ci>, errors=0x7f560d6d997c) at /data/src/10.4/sql/sql_string.cc:441
#9  0x000055e54b13d63d in Item_func::val_str_from_val_str_ascii (this=0x7f55fc014df0, str=0x7f55fc014e20, ascii_buffer=0x7f55fc014eb0) at /data/src/10.4/sql/item_strfunc.cc:116
#10 0x000055e54afe5200 in Item_str_ascii_func::val_str (this=0x7f55fc014df0, str=0x7f55fc014e20) at /data/src/10.4/sql/item_strfunc.h:93
#11 0x000055e54b0a6baf in Item::save_str_in_field (this=0x7f55fc014df0, field=0x7f55fc05b0f8, no_conversions=true) at /data/src/10.4/sql/item.cc:6677
#12 0x000055e54af2d49e in Type_handler_string_result::Item_save_in_field (this=0x55e54c2cedd0 <type_handler_varchar>, item=0x7f55fc014df0, field=0x7f55fc05b0f8, no_conversions=true) at /data/src/10.4/sql/sql_type.cc:3817
#13 0x000055e54b0a6efb in Item::save_in_field (this=0x7f55fc014df0, field=0x7f55fc05b0f8, no_conversions=true) at /data/src/10.4/sql/item.cc:6725
#14 0x000055e54ac6de05 in Item_result_field::save_in_result_field (this=0x7f55fc014df0, no_conversions=true) at /data/src/10.4/sql/item.h:3259
#15 0x000055e54ad916ca in copy_funcs (func_ptr=0x7f55fc05adb8, thd=0x7f55fc000d90) at /data/src/10.4/sql/sql_select.cc:25716
#16 0x000055e54b183a6f in Item_func_group_concat::add (this=0x7f55fc014f50) at /data/src/10.4/sql/item_sum.cc:3993
#17 0x000055e54b185ce6 in Aggregator_simple::add (this=0x7f55fc0181f8) at /data/src/10.4/sql/item_sum.h:716
#18 0x000055e54ad9e82f in Item_sum::aggregator_add (this=0x7f55fc014f50) at /data/src/10.4/sql/item_sum.h:558
#19 0x000055e54ad9162a in update_sum_func (func_ptr=0x7f55fc016ad0) at /data/src/10.4/sql/sql_select.cc:25686
#20 0x000055e54ad87c03 in end_send_group (join=0x7f55fc016428, join_tab=0x7f55fc017a80, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:21997
#21 0x000055e54ad84760 in evaluate_join_record (join=0x7f55fc016428, join_tab=0x7f55fc0176d8, error=0) at /data/src/10.4/sql/sql_select.cc:20815
#22 0x000055e54ad84166 in sub_select (join=0x7f55fc016428, join_tab=0x7f55fc0176d8, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:20627
#23 0x000055e54ad83476 in do_select (join=0x7f55fc016428, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:20126
#24 0x000055e54ad57df9 in JOIN::exec_inner (this=0x7f55fc016428) at /data/src/10.4/sql/sql_select.cc:4534
#25 0x000055e54ad56f28 in JOIN::exec (this=0x7f55fc016428) at /data/src/10.4/sql/sql_select.cc:4316
#26 0x000055e54ad586a7 in mysql_select (thd=0x7f55fc000d90, tables=0x7f55fc015428, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f55fc016400, unit=0x7f55fc004cc0, select_lex=0x7f55fc014850) at /data/src/10.4/sql/sql_select.cc:4755
#27 0x000055e54ad47ec6 in handle_select (thd=0x7f55fc000d90, lex=0x7f55fc004c00, result=0x7f55fc016400, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:436
#28 0x000055e54ad0c797 in execute_sqlcom_select (thd=0x7f55fc000d90, all_tables=0x7f55fc015428) at /data/src/10.4/sql/sql_parse.cc:6449
#29 0x000055e54ad02f64 in mysql_execute_command (thd=0x7f55fc000d90) at /data/src/10.4/sql/sql_parse.cc:3963
#30 0x000055e54ad107c9 in mysql_parse (thd=0x7f55fc000d90, rawbuf=0x7f55fc014798 "SELECT GROUP_CONCAT(PASSWORD(a)) AS f FROM t", length=44, parser_state=0x7f560d6db4d0, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
#31 0x000055e54acfcad1 in dispatch_command (command=COM_QUERY, thd=0x7f55fc000d90, packet=0x7f55fc00abf1 "", packet_length=44, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#32 0x000055e54acfb337 in do_command (thd=0x7f55fc000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#33 0x000055e54ae8da20 in do_handle_one_connection (connect=0x55e54df3b400) at /data/src/10.4/sql/sql_connect.cc:1420
#34 0x000055e54ae8d6b9 in handle_one_connection (arg=0x55e54df3b400) at /data/src/10.4/sql/sql_connect.cc:1316
#35 0x000055e54b8bf748 in pfs_spawn_thread (arg=0x55e54de90dd0) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#36 0x00007f5613d70609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#37 0x00007f5613943293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on 10.4+, with at least MyISAM and InnoDB.
Not reproducible on 10.3.
No obvious problem on a non-debug build.



 Comments   
Comment by Alexander Barkov [ 2021-11-02 ]

Hello serg,

Can you please review a patch for this bug:

https://github.com/MariaDB/server/tree/bb-10.4-MDEV-26953

Thanks.

Comment by Sergei Golubchik [ 2022-01-12 ]

25191a419e98e0 is ok to push

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