Bug #77993 handle_fatal_signal (sig=6) in my_mbcharlen_utf16 | /strings/ctype-ucs2.c:1421
Submitted: 8 Aug 2015 9:27 Modified: 8 Aug 2015 16:42
Reporter: Ramesh Sivaraman (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:5.6.26, 5.7.8 OS:CentOS (CentOS 7)
Assigned to: CPU Architecture:Any
Tags: debug

[8 Aug 2015 9:27] Ramesh Sivaraman
Description:
When we start mysql server with --character-set-server=utf16le option, LOAD DATA INFILE statement crashing server.

GDB

#0  0x00007f9b79136771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000a945ea in my_write_core (sig=6) at /sda/mysql-server-5.6/mysys/stacktrace.c:422
#2  0x0000000000726d14 in handle_fatal_signal (sig=6) at /sda/mysql-server-5.6/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007f9b77f425d7 in raise () from /lib64/libc.so.6
#5  0x00007f9b77f43cc8 in abort () from /lib64/libc.so.6
#6  0x00007f9b77f3b546 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f9b77f3b5f2 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000e42fd2 in my_mbcharlen_utf16 (cs=0x1710c40 <my_charset_utf16le_general_ci>, c=254) at /sda/mysql-server-5.6/strings/ctype-ucs2.c:1421
#9  0x000000000099d38c in READ_INFO::read_field (this=0x7f9b796ec080) at /sda/mysql-server-5.6/sql/sql_load.cc:1609
#10 0x000000000099b707 in read_sep_field (thd=0x7f9b687dc000, info=..., table_list=0x7f9b5a81f168, fields_vars=..., set_fields=..., set_values=..., read_info=..., enclosed=..., skip_lines=0, ignore_check_option_errors=false) at /sda/mysql-server-5.6/sql/sql_load.cc:988
#11 0x000000000099a1f1 in mysql_load (thd=0x7f9b687dc000, ex=0x7f9b5a81f0e0, table_list=0x7f9b5a81f168, fields_vars=..., set_fields=..., set_values=..., handle_duplicates=DUP_ERROR, ignore=false, read_file_from_client=false) at /sda/mysql-server-5.6/sql/sql_load.cc:519
#12 0x00000000007d5c16 in mysql_execute_command (thd=0x7f9b687dc000) at /sda/mysql-server-5.6/sql/sql_parse.cc:3709
#13 0x00000000007dcbc1 in mysql_parse (thd=0x7f9b687dc000, rawbuf=0x7f9b5a81f010 "LOAD DATA INFILE \"t1.MYI\" into TABLE t1", length=39, parser_state=0x7f9b796ed6a0) at /sda/mysql-server-5.6/sql/sql_parse.cc:6386
#14 0x00000000007cfdb0 in dispatch_command (command=COM_QUERY, thd=0x7f9b687dc000, packet=0x7f9b61f58001 "LOAD DATA INFILE \"t1.MYI\" into TABLE t1", packet_length=39) at /sda/mysql-server-5.6/sql/sql_parse.cc:1340
#15 0x00000000007cee03 in do_command (thd=0x7f9b687dc000) at /sda/mysql-server-5.6/sql/sql_parse.cc:1037
#16 0x0000000000796805 in do_handle_one_connection (thd_arg=0x7f9b687dc000) at /sda/mysql-server-5.6/sql/sql_connect.cc:982
#17 0x00000000007962ee in handle_one_connection (arg=0x7f9b687dc000) at /sda/mysql-server-5.6/sql/sql_connect.cc:898
#18 0x0000000000df83d5 in pfs_spawn_thread (arg=0x7f9b763f2600) at /sda/mysql-server-5.6/storage/perfschema/pfs.cc:1860
#19 0x00007f9b79131df5 in start_thread () from /lib64/libpthread.so.0
#20 0x00007f9b780031ad in clone () from /lib64/libc.so.6

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t1(pk int(1),cdk date,cdnk date,ctnk time,cvck CHAR (1),cvcnk varchar(1),KEY cvck (cvck)) ENGINE=MyISAM;
LOAD DATA INFILE "t1.MYI" into TABLE t1;

The attached tarball gives the testcase as an exact match of our system,
including some handy utilities

$ vi {epoch}_mybase # Update base path in this file (the only change
required!). For non-binary distribution please update SOURCE_DIR
location also.
$ ./{epoch}_init # Initializes the data dir
$ ./{epoch}_start # Starts mysqld
$ ./{epoch}_cl # To check mysqld is up
$ ./{epoch}_run # Run the testcase with pquery binary(produces
output)
$ vi /dev/shm/{epoch}/error.log.out # Verify the error log
$ ./{epoch}_gdb # Brings you to a gdb prompt attached to correct
mysqld
& generated core
$ ./{epoch}_parse_core # Create {epoch}_STD.gdb and {epoch}_FULL.gdb;
standard and full var gdb stack traces
etc.
[8 Aug 2015 9:28] Ramesh Sivaraman
Testcase bundle

Attachment: 1438940927_bug_bundle.tar.gz (application/gzip, text), 1009.95 KiB.

[8 Aug 2015 16:42] Umesh Shastry
Hello Ramesh,

Thank you for the report and test case.
Observed that 5.6.26, 5.7.8 debug builds are affected.

Thanks,
Umesh
[9 Aug 2015 16:33] Shane Bester
i recently filed a similar (not a duplicate) bug.
Bug 21542698 - LOAD DATA INFILE: ASSERTION FAILED: ML == 2 || ML == 4
[26 Aug 2016 10:10] Roel Van de Paar
DROP DATABASE test;CREATE DATABASE test;USE test;
SET @@SESSION.collation_database=utf16_polish_ci;
CREATE TEMPORARY TABLE t2(c1 YEAR,c2 DECIMAL(0,0),c3 DECIMAL(0,0) ZEROFILL) ENGINE=InnoDB;
INSERT INTO t2 VALUES(0,1e3,1.e+3);
SELECT * FROM t2 INTO OUTFILE 'out6';
CREATE TABLE t3(c1 CHAR (1)KEY,c2 DATETIME(1),c3 INT(1)) ENGINE=InnoDB;
LOAD DATA INFILE 'out6' INTO TABLE t3;
[18 Sep 2017 7:26] John Embretsen
Posted by developer:
 
A potentially simpler testcase:

First, create a file /tmp/somefile.txt with some content.
Start the server including the --secure_file_priv='/tmp' option.
(The location is not important, it can be anything really)

CREATE TABLE B (a INT);
LOAD DATA INFILE '/tmp/somefile.txt' INTO TABLE B CHARACTER SET utf16;

*poof*