Bug #85059 Assertion `length > 0' failed. in sql/field.cc:8732
Submitted: 18 Feb 2017 4:54 Modified: 17 Apr 2017 14:36
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S1 (Critical)
Version:5.7.17 OS:Any
Assigned to: CPU Architecture:Any

[18 Feb 2017 4:54] Roel Van de Paar
Description:
Core was generated by `/sda/MS010217-mysql-5.7.17-linux-x86_64-debug/bin/mysqld --no-defaults --basedi'.
Program terminated with signal 6, Aborted.
#0  0x00007f814cced741 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
61        val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
(gdb) bt
#0  0x00007f814cced741 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x0000000001826d71 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.c:249
#2  0x0000000000e75574 in handle_fatal_signal (sig=6) at /git/mysql-server_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007f814b0811d7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007f814b0828c8 in __GI_abort () at abort.c:90
#6  0x00007f814b07a146 in __assert_fail_base (fmt=0x7f814b1cb3a8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x1d6f49c "length > 0",
    file=file@entry=0x1d6ead8 "/git/mysql-server_dbg/sql/field.cc", line=line@entry=8732,
    function=function@entry=0x1d731e0 <Field_geom::store_internal(char const*, unsigned long, charset_info_st const*)::__PRETTY_FUNCTION__> "virtual type_conversion_status Field_geom::store_internal(const char*, size_t, const CHARSET_INFO*)") at assert.c:92
#7  0x00007f814b07a1f2 in __GI___assert_fail (assertion=0x1d6f49c "length > 0", file=0x1d6ead8 "/git/mysql-server_dbg/sql/field.cc", line=8732,
    function=0x1d731e0 <Field_geom::store_internal(char const*, unsigned long, charset_info_st const*)::__PRETTY_FUNCTION__> "virtual type_conversion_status Field_geom::store_internal(const char*, size_t, const CHARSET_INFO*)") at assert.c:101
#8  0x0000000000ec78fe in Field_geom::store_internal (this=0x7f810f058860, from=0x7f810f032464 "", length=0, cs=0x2ab49e0 <my_charset_bin>)
    at /git/mysql-server_dbg/sql/field.cc:8732
#9  0x0000000000ec6258 in Field_blob::store (this=0x7f810f058860, from=0x7f810f032464 "", length=0, cs=0x2ab49e0 <my_charset_bin>) at /git/mysql-server_dbg/sql/field.cc:8265
#10 0x0000000000ec7499 in Field_blob::unpack (this=0x7f810f058860, to=0x7f810f058830 "", from=0x7f810f032460 "", param_data=0, low_byte_first=true)
    at /git/mysql-server_dbg/sql/field.cc:8623
#11 0x0000000001420c9a in Field::unpack (this=0x7f810f058860, to=0x7f810f058830 "", from=0x7f810f032460 "") at /git/mysql-server_dbg/sql/field.h:1384
#12 0x00000000018cf3c2 in ha_archive::unpack_row (this=0x7f810f0db030, file_to_read=0x7f810f0db2e0, record=0x7f810f058830 "")
    at /git/mysql-server_dbg/storage/archive/ha_archive.cc:1258
#13 0x00000000018cf43a in ha_archive::get_row_version3 (this=0x7f810f0db030, file_to_read=0x7f810f0db2e0, buf=0x7f810f058830 "")
    at /git/mysql-server_dbg/storage/archive/ha_archive.cc:1269
#14 0x00000000018cef1e in ha_archive::get_row (this=0x7f810f0db030, file_to_read=0x7f810f0db2e0, buf=0x7f810f058830 "")
    at /git/mysql-server_dbg/storage/archive/ha_archive.cc:1169
#15 0x00000000018cf95f in ha_archive::rnd_next (this=0x7f810f0db030, buf=0x7f810f058830 "") at /git/mysql-server_dbg/storage/archive/ha_archive.cc:1375
#16 0x0000000000ef1a0a in handler::ha_rnd_next (this=0x7f810f0db030, buf=0x7f810f058830 "") at /git/mysql-server_dbg/sql/handler.cc:2947
#17 0x000000000141fa26 in rr_sequential (info=0x7f814d2db700) at /git/mysql-server_dbg/sql/records.cc:510
#18 0x000000000158d0a5 in copy_data_between_tables (psi=0x7f8144c21fa8, from=0x7f810f088220, to=0x7f810f144e20, create=..., copied=0x7f814d2ddae8, deleted=0x7f814d2ddae0,
    keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x7f814d2dd020) at /git/mysql-server_dbg/sql/sql_table.cc:10277
#19 0x000000000158b791 in mysql_alter_table (thd=0x7f810f019000, new_db=0x7f810f02bf88 "test", new_name=0x0, create_info=0x7f814d2ddcc0, table_list=0x7f810f02ba00,
    alter_info=0x7f814d2ddc10) at /git/mysql-server_dbg/sql/sql_table.cc:9828
#20 0x0000000001702077 in Sql_cmd_alter_table::execute (this=0x7f810f02c160, thd=0x7f810f019000) at /git/mysql-server_dbg/sql/sql_alter.cc:316
#21 0x00000000014f97f7 in mysql_execute_command (thd=0x7f810f019000, first_level=true) at /git/mysql-server_dbg/sql/sql_parse.cc:4893
#22 0x00000000014fb5f5 in mysql_parse (thd=0x7f810f019000, parser_state=0x7f814d2df550) at /git/mysql-server_dbg/sql/sql_parse.cc:5611
#23 0x00000000014f0c1d in dispatch_command (thd=0x7f810f019000, com_data=0x7f814d2dfcb0, command=COM_QUERY) at /git/mysql-server_dbg/sql/sql_parse.cc:1461
#24 0x00000000014efa44 in do_command (thd=0x7f810f019000) at /git/mysql-server_dbg/sql/sql_parse.cc:999
#25 0x000000000161f9d0 in handle_connection (arg=0x7f81223ed860) at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:300
#26 0x00000000018534f9 in pfs_spawn_thread (arg=0x7f8130a76220) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2188
#27 0x00007f814cce8dc5 in start_thread (arg=0x7f814d2e0700) at pthread_create.c:308
#28 0x00007f814b14373d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Query (7f810f02b030): ALTER TABLE t0 ADD c TIMESTAMP DEFAULT '0-0-0 0:0:0'

How to repeat:
The attached tarball (1486932221_bug_bundle.tar.gz) gives the testcase as an exact match of our system, including some handy utilities

$ vi 1486932221_mybase         # STEP1: Update the base path in this file (usually the only change required!). If you use a non-binary distribution, please update SOURCE_DIR location also
$ ./1486932221_init            # STEP2: Initializes the data dir
$ ./1486932221_start           # STEP3: Starts mysqld
$ ./1486932221_cl              # STEP4: To check mysqld is up
$ ./1486932221_run_pquery      # STEP5: Run the testcase with the pquery binary
$ ./1486932221_run             # OPTIONAL: Run the testcase with the mysql CLI (may not reproduce the issue, as the pquery binary was used for the original testcase reduction)
$ vi /dev/shm/1486932221/error.log.out  # STEP6: Verify the error log
$ ./1486932221_gdb             # OPTIONAL: Brings you to a gdb prompt with gdb attached to the used mysqld and attached to the generated core
$ ./1486932221_parse_core      # OPTIONAL: Creates 1486932221_STD.gdb and 1486932221_FULL.gdb; standard and full variables gdb stack traces
[18 Feb 2017 11:39] MySQL Verification Team
Hello Roel,

Thank you for the report.
May be you forgot to attache test case/tarball?

Thanks,
Umesh
[19 Feb 2017 22:18] Roel Van de Paar
1486932221_bug_bundle.tar.gz

Attachment: 1486932221_bug_bundle.tar.gz (application/x-gzip, text), 1.79 MiB.

[19 Feb 2017 22:20] Roel Van de Paar
Hi Umesh, Yes, thank you :) Done
[20 Feb 2017 7:03] MySQL Verification Team
Thank you, observed that 5.7.17 debug build is affected.

-- only debug build affacted

rm -rf 85070
bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/85070 -v
bin/mysqld-debug --no-defaults --basedir=$PWD --datadir=$PWD/85070 --core-file --socket=/tmp/mysql_ushastry.sock --port=3306 --log-error=$PWD/85070/log.err 2>&1 &

-- if required, set sql_mode='' 
3rd attempt with the below test case triggered crash

DROP DATABASE test;CREATE DATABASE test;USE test;
SET default_storage_engine=ARCHIVE;#NOERROR
CREATE TABLE t0(line LINESTRING NOT NULL)engine=aria;#NOERROR
INSERT INTO t0 VALUES(null),(null),(null),(null),(null),(null);#NOERROR
ALTER TABLE t0 ADD c TIMESTAMP DEFAULT '0-0-0 0:0:0';

(gdb) bt
#0  0x00007f32386d3771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x00000000018bfe19 in my_write_core (sig=6) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/mysys/stacktrace.c:249
#2  0x0000000000ecba80 in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007f32372d95d7 in raise () from /lib64/libc.so.6
#5  0x00007f32372dacc8 in abort () from /lib64/libc.so.6
#6  0x00007f32372d2546 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f32372d25f2 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000f1b1c1 in Field_geom::store_internal (this=0x7f31d8010b70, from=0x7f31d8010fa4 "", length=0, cs=0x2d97e20 <my_charset_bin>)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/field.cc:8732
#9  0x0000000000f19a07 in Field_blob::store (this=0x7f31d8010b70, from=0x7f31d8010fa4 "", length=0, cs=0x2d97e20 <my_charset_bin>)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/field.cc:8265
#10 0x0000000000f1ad3d in Field_blob::unpack (this=0x7f31d8010b70, to=0x7f31d8010b40 "", from=0x7f31d8010fa0 "", param_data=0, low_byte_first=true)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/field.cc:8623
#11 0x00000000014a3046 in Field::unpack (this=0x7f31d8010b70, to=0x7f31d8010b40 "", from=0x7f31d8010fa0 "") at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/field.h:1384
#12 0x0000000001dacc30 in ha_archive::unpack_row (this=0x7f31d803dc70, file_to_read=0x7f31d803df20, record=0x7f31d8010b40 "")
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/storage/archive/ha_archive.cc:1258
#13 0x0000000001daccb2 in ha_archive::get_row_version3 (this=0x7f31d803dc70, file_to_read=0x7f31d803df20, buf=0x7f31d8010b40 "")
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/storage/archive/ha_archive.cc:1269
#14 0x0000000001dac77e in ha_archive::get_row (this=0x7f31d803dc70, file_to_read=0x7f31d803df20, buf=0x7f31d8010b40 "")
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/storage/archive/ha_archive.cc:1169
#15 0x0000000001dad1d8 in ha_archive::rnd_next (this=0x7f31d803dc70, buf=0x7f31d8010b40 "") at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/storage/archive/ha_archive.cc:1375
#16 0x0000000000f45d48 in handler::ha_rnd_next (this=0x7f31d803dc70, buf=0x7f31d8010b40 "") at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/handler.cc:2947
#17 0x00000000014a1e14 in rr_sequential (info=0x7f322c05bb40) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/records.cc:510
#18 0x00000000016175e9 in copy_data_between_tables (psi=0x7f3233b012e8, from=0x7f31d8010190, to=0x7f31d801c350, create=..., copied=0x7f322c05d5a8, deleted=0x7f322c05d5a0,
    keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x7f322c05bdb0) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_table.cc:10277
#19 0x0000000001615c15 in mysql_alter_table (thd=0x7f31d8000b70, new_db=0x7f31d80064e8 "test", new_name=0x0, create_info=0x7f322c05dc40, table_list=0x7f31d8005f60, alter_info=0x7f322c05dd40)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_table.cc:9823
#20 0x0000000001797605 in Sql_cmd_alter_table::execute (this=0x7f31d80066a8, thd=0x7f31d8000b70) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_alter.cc:316
#21 0x0000000001580cec in mysql_execute_command (thd=0x7f31d8000b70, first_level=true) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:4893
#22 0x0000000001582c75 in mysql_parse (thd=0x7f31d8000b70, parser_state=0x7f322c05f690) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:5611
#23 0x00000000015774f6 in dispatch_command (thd=0x7f31d8000b70, com_data=0x7f322c05fe00, command=COM_QUERY)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:1461
#24 0x00000000015762f9 in do_command (thd=0x7f31d8000b70) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:999
#25 0x00000000016abfc4 in handle_connection (arg=0x413b730) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/conn_handler/connection_handler_per_thread.cc:300
#26 0x000000000194c420 in pfs_spawn_thread (arg=0x4129980) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/storage/perfschema/pfs.cc:2188
#27 0x00007f32386cedf5 in start_thread () from /lib64/libpthread.so.0
#28 0x00007f323739a60d in clone () from /lib64/libc.so.6
(gdb)
[17 Apr 2017 14:36] Paul DuBois
Posted by developer:
 
Noted in 8.0.2 changelog.

Failure occurred for ALTER TABLE on an ARCHIVE table containing a NOT
NULL column having a geometry data type. For debug builds, an
assertion was raised. For non-debug builds, an error occurred.