Bug #56120 Assertion `time <= (838*10000 + 59*100 + 59)' failed on negative TIME
Submitted: 19 Aug 2010 14:10 Modified: 3 Oct 2010 1:34
Reporter: Nirbhay Choubey Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.5.6-m3, 5.6.99-m5 OS:Any
Assigned to: Evgeny Potemkin CPU Architecture:Any
Tags: mysql-5.5, mysql-5.5-bugfixing, next-mr, regression
Triage: Triaged: D1 (Critical)

[19 Aug 2010 14:10] Nirbhay Choubey
Description:
builds/source/mysql-5.5/sql/item.cc:7513: virtual String* Item_cache_datetime::val_str(String*): Assertion `time <= (838*10000 + 59*100 + 59)' failed.
100819 17:00:52 - mysqld got signal 6 ;

#0  0xb7842430 in __kernel_vsyscall ()
#0  0xb7842430 in __kernel_vsyscall ()
#1  0xb7822093 in pthread_kill () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x0861ae43 in my_write_core (sig=6) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/mysys/stacktrace.c:328
#3  0x0815fcd6 in handle_segfault (sig=6) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/mysqld.cc:2506
#4  <signal handler called>
#5  0xb7842430 in __kernel_vsyscall ()
#6  0xb756b651 in raise () from /lib/tls/i686/cmov/libc.so.6
#7  0xb756ea82 in abort () from /lib/tls/i686/cmov/libc.so.6
#8  0xb7564718 in __assert_fail () from /lib/tls/i686/cmov/libc.so.6
#9  0x08351696 in Item_cache_datetime::val_str (this=0xaa3c238, str=0xb096115c) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/item.cc:7513
#10 0x083affa0 in Item_sum_hybrid::val_str (this=0xaa3a918, str=0xb096115c) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/item_sum.cc:1941
#11 0x0833eb74 in Item::val_str_ascii (this=0xaa3a918, str=0xb096115c) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/item.cc:232
#12 0x08340e5a in Item::get_time (this=0xaa3a918, ltime=0xb09611e4) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/item.cc:1031
#13 0x0834d5ee in Item::send (this=0xaa3a918, protocol=0xa9ada04, buffer=0xb0961284) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/item.cc:5902
#14 0x0816e32c in Protocol::send_result_set_row (this=0xa9ada04, row_items=0xaa3c11c) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/protocol.cc:866
#15 0x081bee4f in select_send::send_data (this=0xaa3afa8, items=...) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_class.cc:1764
#16 0x08232065 in end_send_group (join=0xaa3afb8, join_tab=0x0, end_of_records=true) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_select.cc:12646
#17 0x0822f584 in do_select (join=0xaa3afb8, fields=0xaa3c11c, table=0x0, procedure=0x0) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_select.cc:11368
#18 0x0821a7d5 in JOIN::exec (this=0xaa3afb8) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_select.cc:2347
#19 0x0821ae5b in mysql_select (thd=0xa9ad668, rref_pointer_array=0xa9aeb58, tables=0xaa3ab98, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, 
    proc_param=0x0, select_options=2147748608, result=0xaa3afa8, unit=0xa9ae634, select_lex=0xa9aea60)
    at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_select.cc:2541
#20 0x082141bc in handle_select (thd=0xa9ad668, lex=0xa9ae5d0, result=0xaa3afa8, setup_tables_done_option=0)
    at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_select.cc:296
#21 0x081f2de5 in execute_sqlcom_select (thd=0xa9ad668, all_tables=0xaa3ab98) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_parse.cc:4874
#22 0x081ea950 in mysql_execute_command (thd=0xa9ad668) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_parse.cc:2308
#23 0x081f4c79 in mysql_parse (thd=0xa9ad668, rawbuf=0xaa3a7f8 "SELECT MAX(c1), MIN(c1) FROM t1", length=31, parser_state=0xb0962af0)
    at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_parse.cc:5903
#24 0x081e81e0 in dispatch_command (command=COM_QUERY, thd=0xa9ad668, packet=0xaa327c9 "", packet_length=31)
    at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_parse.cc:1138
#25 0x081e7614 in do_command (thd=0xa9ad668) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_parse.cc:810
#26 0x082bd7d9 in do_handle_one_connection (thd_arg=0xa9ad668) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_connect.cc:1191
#27 0x082bd68a in handle_one_connection (arg=0xa9ad668) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/sql/sql_connect.cc:1130
#28 0x085e1580 in pfs_spawn_thread (arg=0xaa15420) at /home/nirbhay/Project/mysql/repo/builds/source/mysql-5.5/storage/perfschema/pfs.cc:1015
#29 0xb781c96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#30 0xb760ea4e in clone () from /lib/tls/i686/cmov/libc.so.6

How to repeat:
USE `test`;
CREATE TABLE `t1`(`c1` TIME NOT NULL);
INSERT INTO t1 VALUES('-0:00:01');
SELECT MAX(c1), MIN(c1) FROM t1;
DROP TABLE t1;
[19 Aug 2010 14:25] Miguel Solorzano
Thank you for the bug report.

100819 11:22:59 InnoDB 1.2.0 started; log sequence number 1612639
100819 11:22:59 [Note] Event Scheduler: Loaded 0 events
100819 11:22:59 [Note] /home/miguel/dbs/5.5/bin/mysqld: ready for connections.
Version: '5.6.99-m4-debug-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
mysqld: /home/miguel/bzr/5.5/sql/item.cc:7514: virtual String* Item_cache_datetime::val_str(String*): Assertion `time < (838*10000 + 59*100 + 59)' failed.
[20 Aug 2010 18:20] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116445

3190 Evgeny Potemkin	2010-08-20
      Bug#56120: Failed assertion on MIX/MAX on negative time value
      The Item_cache_datetime::val_str function wasn't taking into account that time
      could be negative. This led to failed assertion.
      Now Item_cache_datetime::val_str correctly converts negative time values
      from integer to string representation.
     @ mysql-test/r/func_group.result
        Added a test case for the bug#56120.
     @ mysql-test/t/func_group.test
        Added a test case for the bug#56120.
     @ sql/item.cc
        Bug#56120: Failed assertion on MIX/MAX on negative time value
        Now Item_cache_datetime::val_str correctly converts negative time values
        from integer to string representation.
[23 Aug 2010 11:39] Nirbhay Choubey
On Windows (Win Server 2007 sp2)the same set of statements produce
different sort of output (and no assertion failure) :

USE `test`;
CREATE TABLE `t1`(`c1` TIME NOT NULL);
INSERT INTO t1 VALUES('-0:00:01');
SELECT MAX(c1), MIN(c1) FROM t1;
MAX(c1)	MIN(c1)
838:59:59	838:59:59       ## Incorrect
Warnings:
Warning	1292	Truncated incorrect time value: '3133608139:16:15'
Warning	1292	Truncated incorrect time value: '3133608139:16:15'
DROP TABLE t1;

IMO, the patch for the above bug should take care of this bug too.
[23 Aug 2010 16:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116537

3190 Evgeny Potemkin	2010-08-23
      Bug#56120: Failed assertion on MIX/MAX on negative time value
      The Item_cache_datetime::val_str function wasn't taking into account that time
      could be negative. This led to failed assertion.
      Now Item_cache_datetime::val_str correctly converts negative time values
      from integer to string representation.
     @ mysql-test/r/func_group.result
        Added a test case for the bug#56120.
     @ mysql-test/t/func_group.test
        Added a test case for the bug#56120.
     @ sql/item.cc
        Bug#56120: Failed assertion on MIX/MAX on negative time value
        Now Item_cache_datetime::val_str correctly converts negative time values
        from integer to string representation.
[25 Aug 2010 9:24] Bugs System
Pushed into mysql-5.5 5.5.6-m3 (revid:alik@ibmvm-20100825092002-2yvkb3iwu43ycpnm) (version source revid:alik@ibmvm-20100825092002-2yvkb3iwu43ycpnm) (merge vers: 5.5.6-m3) (pib:20)
[25 Aug 2010 12:23] Alexander Nozdrin
It is not pushed actually to mysql-5.5.
It's still queuing in 5.5-bugfixing.
[26 Aug 2010 2:02] Paul Dubois
Back to Patch Queued per Alik's comment.
[30 Aug 2010 8:32] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100830082732-n2eyijnv86exc5ci) (version source revid:alik@sun.com-20100830082732-n2eyijnv86exc5ci) (merge vers: 5.6.1-m4) (pib:21)
[30 Aug 2010 8:35] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100830082745-n6sh01wlwh3itasv) (version source revid:alik@sun.com-20100830082745-n6sh01wlwh3itasv) (pib:21)
[30 Aug 2010 8:36] Bugs System
Pushed into mysql-5.5 5.5.7-m3 (revid:alik@sun.com-20100830082727-5ac4czrxl61w9wle) (version source revid:alik@sun.com-20100830082727-5ac4czrxl61w9wle) (merge vers: 5.5.7-m3) (pib:21)
[8 Sep 2010 19:23] Paul Dubois
Noted in 5.5.7, 5.6.1 changelogs.

A negative TIME argument to MIN() or MAX() could raise an assertion.
[10 Sep 2010 18:51] Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:joerg@mysql.com-20100910184813-csdto6tk4nlogrsq) (version source revid:dlenev@mysql.com-20100831090419-rzr5ktekby2gspm1) (merge vers: 5.5.6-m3) (pib:21)
[13 Sep 2010 13:49] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:dlenev@mysql.com-20100913103627-p2oqplu42x1gv2bd) (version source revid:dlenev@mysql.com-20100831090419-rzr5ktekby2gspm1) (merge vers: 5.5.6-m3) (pib:21)
[13 Sep 2010 13:52] Bugs System
Pushed into mysql-next-mr (revid:dlenev@mysql.com-20100913121556-sfxqlpj9kbc28kaf) (version source revid:dlenev@mysql.com-20100831090419-rzr5ktekby2gspm1) (pib:21)