Bug #74946 Assertion `nr >= 0.0' failed in virtual double Item_sum_std::val_real()
Submitted: 21 Nov 2014 4:47 Modified: 21 Nov 2014 5:44
Reporter: Ramesh Sivaraman (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6.20, 5.6.23, 5.7.6 OS:Linux (CentOS 7)
Assigned to: CPU Architecture:Any
Tags: debug

[21 Nov 2014 4:47] Ramesh Sivaraman
Description:
Version: '5.6.20-debug'  socket: '/ssd/ramesh/mysql-server/mysql-5.6.20-linux-x86_64-debug/socket.sock'  port: 15948  MySQL Community Server (GPL)
mysqld: /ssd/ramesh/mysql-server/mysql-5.6/sql/item_sum.cc:1768: virtual double Item_sum_std::val_real(): Assertion `nr >= 0.0' failed.
04:21:22 UTC - mysqld got signal 6 ;

*** gdb info

#0  0x00007f7cb64dd771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000a9035e in my_write_core (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/mysys/stacktrace.c:422
#2  0x0000000000723688 in handle_fatal_signal (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007f7cb52e95c9 in raise () from /lib64/libc.so.6
#5  0x00007f7cb52eacd8 in abort () from /lib64/libc.so.6
#6  0x00007f7cb52e2536 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f7cb52e25e2 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000006e1f48 in Item_sum_std::val_real (this=0x7f7c1941faa8) at /ssd/ramesh/mysql-server/mysql-5.6/sql/item_sum.cc:1768
#9  0x000000000065d39b in Item::send (this=0x7f7c1941faa8, protocol=0x7f7c233244d8, buffer=0x7f7cb6ad3490) at /ssd/ramesh/mysql-server/mysql-5.6/sql/item.cc:6856
#10 0x000000000071b320 in Protocol::send_result_set_row (this=0x7f7c233244d8, row_items=0x7f7c194742e8) at /ssd/ramesh/mysql-server/mysql-5.6/sql/protocol.cc:847
#11 0x0000000000788eb9 in select_send::send_data (this=0x7f7c19420c60, items=...) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_class.cc:2499
#12 0x00000000007a42b2 in end_send_group (join=0x7f7c19474010, join_tab=0x7f7c194758b0, end_of_records=true) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_executor.cc:2908
#13 0x00000000007a04d1 in sub_select (join=0x7f7c19474010, join_tab=0x7f7c194755b0, end_of_records=true) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_executor.cc:1209
#14 0x00000000007a0031 in do_select (join=0x7f7c19474010) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_executor.cc:935
#15 0x000000000079df61 in JOIN::exec (this=0x7f7c19474010) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_executor.cc:194
#16 0x00000000007fe143 in mysql_execute_select (thd=0x7f7c23324000, select_lex=0x7f7c23326878, free_join=true) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_select.cc:1100
#17 0x00000000007fe43f in mysql_select (thd=0x7f7c23324000, tables=0x7f7c19420648, wild_num=0, fields=..., conds=0x0, order=0x7f7c23326a40, group=0x7f7c23326978, having=0x0, select_options=2147756800, result=0x7f7c19420c60, unit=0x7f7c23326230, select_lex=0x7f7c23326878) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_select.cc:1221
#18 0x00000000007fc4c7 in handle_select (thd=0x7f7c23324000, result=0x7f7c19420c60, setup_tables_done_option=0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_select.cc:110
#19 0x00000000007d681b in execute_sqlcom_select (thd=0x7f7c23324000, all_tables=0x7f7c19420648) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:5103
#20 0x00000000007cf5cb in mysql_execute_command (thd=0x7f7c23324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:2649
#21 0x00000000007d8fa4 in mysql_parse (thd=0x7f7c23324000, rawbuf=0x7f7c1941f010 "select count(b),sum(b),avg(b),std(b),min(b),max(b),bit_and(b),bit_or(b) FROM t1", length=79, parser_state=0x7f7cb6ad4e70) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:6245
#22 0x00000000007cc557 in dispatch_command (command=COM_QUERY, thd=0x7f7c23324000, packet=0x7f7c23362001 "", packet_length=79) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1332
#23 0x00000000007cb646 in do_command (thd=0x7f7c23324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1034
#24 0x0000000000793a61 in do_handle_one_connection (thd_arg=0x7f7c23324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:982
#25 0x000000000079354a in handle_one_connection (arg=0x7f7c23324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:898
#26 0x0000000000ad4b5c in pfs_spawn_thread (arg=0x7f7cb0ffeb00) at /ssd/ramesh/mysql-server/mysql-5.6/storage/perfschema/pfs.cc:1860
#27 0x00007f7cb64d8df3 in start_thread () from /lib64/libpthread.so.0
#28 0x00007f7cb53aa01d in clone () from /lib64/libc.so.6

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
SET SQL_WARNINGS=1;
CREATE TEMPORARY TABLE t1(b CHAR(60));
insert INTO t1 values("1e+1000"),("1e-1000"),("-1e+1000");
select count(b),sum(b),avg(b),std(b),min(b),max(b),bit_and(b),bit_or(b) FROM t1;
[21 Nov 2014 5:44] MySQL Verification Team
Hello Ramesh Sivaraman,

Thank you for the report and test case.
Confirmed that 5.6.23/5.7.6 debug builds are affected.

Thanks,
Umesh
[21 Nov 2014 5:45] MySQL Verification Team
// 5.6.23 debug build

(gdb) bt
#0  __pthread_kill (threadid=<value optimized out>, signo=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:63
#1  0x0000000000affdab in my_write_core (sig=6) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/mysys/stacktrace.c:422
#2  0x000000000077ebbc in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x0000003deac32625 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#5  0x0000003deac33e05 in abort () at abort.c:92
#6  0x0000003deac2b74e in __assert_fail_base (fmt=<value optimized out>, assertion=0xfff9b6 "nr >= 0.0",
    file=0xfff840 "/export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/item_sum.cc", line=<value optimized out>, function=<value optimized out>) at assert.c:96
#7  0x0000003deac2b810 in __assert_fail (assertion=0xfff9b6 "nr >= 0.0", file=0xfff840 "/export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/item_sum.cc", line=1768,
    function=0x1000960 "virtual double Item_sum_std::val_real()") at assert.c:105
#8  0x000000000073c30f in Item_sum_std::val_real (this=0x7f9f78007818) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/item_sum.cc:1768
#9  0x00000000006b53e4 in Item::send (this=0x7f9f78007818, protocol=0x417c9f8, buffer=0x7f9f9e592a80) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/item.cc:6895
#10 0x00000000007767d7 in Protocol::send_result_set_row (this=0x417c9f8, row_items=0x7f9f7801fcb8) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/protocol.cc:847
#11 0x00000000007e61dd in select_send::send_data (this=0x7f9f780089d0, items=...) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_class.cc:2506
#12 0x0000000000801b66 in end_send_group (join=0x7f9f7801f9e0, join_tab=0x7f9f78021280, end_of_records=true)
    at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_executor.cc:2908
#13 0x00000000007fdc17 in sub_select (join=0x7f9f7801f9e0, join_tab=0x7f9f78020f80, end_of_records=true)
    at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_executor.cc:1209
#14 0x00000000007fd78a in do_select (join=0x7f9f7801f9e0) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_executor.cc:935
#15 0x00000000007fb60b in JOIN::exec (this=0x7f9f7801f9e0) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_executor.cc:194
#16 0x000000000085d734 in mysql_execute_select (thd=0x417c520, select_lex=0x417ed98, free_join=true)
    at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_select.cc:1100
#17 0x000000000085da4b in mysql_select (thd=0x417c520, tables=0x7f9f780083b8, wild_num=0, fields=..., conds=0x0, order=0x417ef60, group=0x417ee98, having=0x0, select_options=2147756800,
    result=0x7f9f780089d0, unit=0x417e750, select_lex=0x417ed98) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_select.cc:1221
#18 0x000000000085ba57 in handle_select (thd=0x417c520, result=0x7f9f780089d0, setup_tables_done_option=0)
    at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_select.cc:110
#19 0x0000000000835384 in execute_sqlcom_select (thd=0x417c520, all_tables=0x7f9f780083b8) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_parse.cc:5103
#20 0x000000000082dadc in mysql_execute_command (thd=0x417c520) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_parse.cc:2649
#21 0x0000000000837fa9 in mysql_parse (thd=0x417c520, rawbuf=0x7f9f78006d80 "select count(b),sum(b),avg(b),std(b),min(b),max(b),bit_and(b),bit_or(b) FROM t1", length=79,
    parser_state=0x7f9f9e594680) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_parse.cc:6357
#22 0x000000000082a92b in dispatch_command (command=COM_QUERY, thd=0x417c520, packet=0x42a7eb1 "", packet_length=79)
    at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_parse.cc:1332
#23 0x0000000000829990 in do_command (thd=0x417c520) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_parse.cc:1034
#24 0x00000000007f0d8f in do_handle_one_connection (thd_arg=0x417c520) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_connect.cc:982
#25 0x00000000007f0860 in handle_one_connection (arg=0x417c520) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/sql/sql_connect.cc:898
#26 0x0000000000e5f509 in pfs_spawn_thread (arg=0x426b5e0) at /export/home/pb2/build/sb_0-13622626-1415294505.52/mysqlcom-pro-5.6.23/storage/perfschema/pfs.cc:1860
#27 0x0000003deb0079d1 in start_thread (arg=0x7f9f9e595700) at pthread_create.c:301
#28 0x0000003deace89dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

[root@cluster-repo mysql-advanced-5.6.23]#  more docs/INFO_SRC
revision-id: michael.izioumtchenko@oracle.com-20141106152508-nntohvuco3v1rjjx
date: 2014-11-06 16:25:08 +0100
build-date: 2014-11-06 18:00:43 +0100
revno: 6243
branch-nick: daily-5.6
MySQL source 5.6.23
[21 Nov 2014 5:45] MySQL Verification Team
// 5.7.6 debug build

(gdb) bt
#0  __pthread_kill (threadid=<value optimized out>, signo=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:63
#1  0x0000000000f983cd in my_write_core (sig=6) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/mysys/stacktrace.c:247
#2  0x0000000000930748 in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/signal_handler.cc:219
#3  <signal handler called>
#4  0x0000003deac32625 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#5  0x0000003deac33e05 in abort () at abort.c:92
#6  0x0000003deac2b74e in __assert_fail_base (fmt=<value optimized out>, assertion=0x1595dae "nr >= 0.0",
    file=0x1595c38 "/export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/item_sum.cc", line=<value optimized out>, function=<value optimized out>) at assert.c:96
#7  0x0000003deac2b810 in __assert_fail (assertion=0x1595dae "nr >= 0.0", file=0x1595c38 "/export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/item_sum.cc", line=1863,
    function=0x1596f40 "virtual double Item_sum_std::val_real()") at assert.c:105
#8  0x0000000000bb4b99 in Item_sum_std::val_real (this=0x7feed4006980) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/item_sum.cc:1863
#9  0x00000000009bc2da in Item::send (this=0x7feed4006980, protocol=0x7feed40011e8, buffer=0x7fef1808d950)
    at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/item.cc:6992
#10 0x0000000000bf6f09 in Protocol::send_result_set_row (this=0x7feed40011e8, row_items=0x7feed4027170)
    at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/protocol.cc:1004
#11 0x0000000000c5933f in select_send::send_data (this=0x7feed4025c60, items=...) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_class.cc:2764
#12 0x0000000000c7509b in end_send_group (join=0x7feed4026ed0, qep_tab=0x7feed4027660, end_of_records=true)
    at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_executor.cc:2981
#13 0x0000000000c70a55 in sub_select (join=0x7feed4026ed0, qep_tab=0x7feed40274e8, end_of_records=true)
    at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_executor.cc:1210
#14 0x0000000000c705d0 in do_select (join=0x7feed4026ed0) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_executor.cc:936
#15 0x0000000000c6e4b4 in JOIN::exec (this=0x7feed4026ed0) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_executor.cc:199
#16 0x0000000000cf1f03 in handle_query (thd=0x7feed4000cf0, lex=0x7feed4002f18, result=0x7feed4025c60, added_options=0, removed_options=0)
    at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_select.cc:180
#17 0x0000000000cbbd1a in execute_sqlcom_select (thd=0x7feed4000cf0, all_tables=0x7feed4025628)
    at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:4986
#18 0x0000000000cb405f in mysql_execute_command (thd=0x7feed4000cf0) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:2487
#19 0x0000000000cbcb3d in mysql_parse (thd=0x7feed4000cf0, parser_state=0x7fef1808f660) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:5386
#20 0x0000000000cb102a in dispatch_command (command=COM_QUERY, thd=0x7feed4000cf0, packet=0x7feed4009891 "", packet_length=79)
    at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:1249
#21 0x0000000000cafdbd in do_command (thd=0x7feed4000cf0) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:833
#22 0x0000000000dbd24c in handle_connection (arg=0x3eff560) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/sql/conn_handler/connection_handler_per_thread.cc:298
#23 0x00000000010189f7 in pfs_spawn_thread (arg=0x3da77d0) at /export/home/pb2/build/sb_0-13679149-1416068314.26/mysqlcom-pro-5.7.6-m16/storage/perfschema/pfs.cc:2137
#24 0x0000003deb0079d1 in start_thread (arg=0x7fef18090700) at pthread_create.c:301
#25 0x0000003deace89dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

[root@cluster-repo mysql-advanced-5.7.6]# more docs/INFO_SRC
git log -1: commit 29eaa2f6ad2e90f669cb536e51af8c3bdf7a4ca9
date: 2014-11-15 14:42:22 +0100
build-date: 2014-11-15 17:05:06 +0100
short: 29eaa2f
branch: mysql-trunk
MySQL source 5.7.6
[23 Nov 2014 9:19] MySQL Verification Team
this is a duplicate of my
Bug #16521799 ASSERTION FAILED: NR >= 0.0 WITH STDDEV