Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-22734

Assertion `mon > 0 && mon < 13' failed in sec_since_epoch

    XMLWordPrintable

    Details

      Description

      While the current testcase is debug-only, this issue may be able to affect opt builds also. It is also a common/simple testcase (with 0 for month) and a serious looking assert. Hence setting the prio to critical ftm. Feel free to adjust if on evaluation it shows not to be a serious bug.

      USE test;
      SET time_zone="-02:00";
      CREATE TABLE t(c TIMESTAMP KEY);
      SELECT * FROM t WHERE c='2010-00-01 00:00:00';
      

      Leads to:

      10.5.4 8569dac1ec9f6853a0b2f3ea9bcbda67644ead24

      mysqld: /test/10.5_dbg/sql/tztime.cc:801: my_time_t sec_since_epoch(int, int, int, int, int, int): Assertion `mon > 0 && mon < 13' failed.
      

      10.5.4 8569dac1ec9f6853a0b2f3ea9bcbda67644ead24

      Core was generated by `/test/MD260520-mariadb-10.5.4-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      [Current thread is 1 (Thread 0x145652b62700 (LWP 2712513))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x000055cd36916d7a in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:518
      #2  0x000055cd360bc385 in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
      #5  0x00001456512a6801 in __GI_abort () at abort.c:79
      #6  0x000014565129639a in __assert_fail_base (fmt=0x14565141d7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55cd36abc7eb "mon > 0 && mon < 13", file=file@entry=0x55cd36abc7ce "/test/10.5_dbg/sql/tztime.cc", line=line@entry=801, function=function@entry=0x55cd36abd260 <sec_since_epoch(int, int, int, int, int, int)::__PRETTY_FUNCTION__> "my_time_t sec_since_epoch(int, int, int, int, int, int)") at assert.c:92
      #7  0x0000145651296412 in __GI___assert_fail (assertion=assertion@entry=0x55cd36abc7eb "mon > 0 && mon < 13", file=file@entry=0x55cd36abc7ce "/test/10.5_dbg/sql/tztime.cc", line=line@entry=801, function=function@entry=0x55cd36abd260 <sec_since_epoch(int, int, int, int, int, int)::__PRETTY_FUNCTION__> "my_time_t sec_since_epoch(int, int, int, int, int, int)") at assert.c:101
      #8  0x000055cd35f2fcfc in sec_since_epoch (year=2010, mon=0, mday=1, hour=0, min=0, sec=0) at /test/10.5_dbg/sql/tztime.cc:801
      #9  0x000055cd35f304a9 in Time_zone_offset::TIME_to_gmt_sec (this=0x14563152e3e8, t=<optimized out>, error_code=0x145652b600cc) at /test/10.5_dbg/sql/tztime.cc:1386
      #10 0x000055cd35f2d821 in TIME_to_timestamp (thd=<optimized out>, t=t@entry=0x145652b60130, error_code=error_code@entry=0x145652b600cc) at /test/10.5_dbg/sql/sql_time.cc:498
      #11 0x000055cd35ff01fe in Timestamp::Timestamp (this=this@entry=0x145652b600d0, thd=<optimized out>, ltime=ltime@entry=0x145652b60130, error_code=error_code@entry=0x145652b600cc) at /test/10.5_dbg/sql/sql_type.cc:398
      #12 0x000055cd35ff0225 in Timestamp_or_zero_datetime::Timestamp_or_zero_datetime (this=0x145652b600d0, thd=<optimized out>, ltime=0x145652b60130, error_code=0x145652b600cc) at /test/10.5_dbg/sql/sql_type.cc:406
      #13 0x000055cd35ff84d4 in Type_handler_timestamp_common::TIME_to_native (this=this@entry=0x55cd37697c00 <type_handler_timestamp2>, thd=thd@entry=0x14562fc15088, ltime=ltime@entry=0x145652b60130, to=to@entry=0x14562fc76830, decimals=0) at /test/10.5_dbg/sql/sql_type.cc:8668
      #14 0x000055cd35ff8618 in Type_handler_timestamp_common::Item_val_native_with_conversion (this=0x55cd37697c00 <type_handler_timestamp2>, thd=0x14562fc15088, item=0x14562fc76608, to=0x14562fc76830) at /test/10.5_dbg/sql/sql_type.cc:8687
      #15 0x000055cd361071e5 in Item::val_native_with_conversion (th=<optimized out>, to=0x14562fc76830, thd=<optimized out>, this=0x14562fc76608) at /test/10.5_dbg/sql/item.h:1320
      #16 cmp_item_timestamp::store_value (this=0x14562fc76818, item=0x14562fc76608) at /test/10.5_dbg/sql/item_cmpfunc.cc:4246
      #17 0x000055cd3610492f in Item_equal::val_int (this=0x14562fc766c0) at /test/10.5_dbg/sql/item_cmpfunc.cc:7142
      #18 0x000055cd35fe0ef4 in Type_handler_int_result::Item_val_bool (this=<optimized out>, item=<optimized out>) at /test/10.5_dbg/sql/sql_type.cc:4915
      #19 0x000055cd35d245ec in Item::val_bool (this=0x14562fc766c0) at /test/10.5_dbg/sql/item.h:1480
      #20 0x000055cd35e4d8e8 in Item::eval_const_cond (this=0x14562fc766c0) at /test/10.5_dbg/sql/item.h:1487
      #21 Item::remove_eq_conds (this=0x14562fc766c0, thd=<optimized out>, cond_value=0x14562fc75f38, top_level_arg=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:17493
      #22 0x000055cd35e8c5b9 in make_join_statistics (keyuse_array=0x14562fc75f10, tables_list=..., join=0x14562fc75c20) at /test/10.5_dbg/sql/sql_select.cc:5305
      #23 JOIN::optimize_inner (this=this@entry=0x14562fc75c20) at /test/10.5_dbg/sql/sql_select.cc:2260
      #24 0x000055cd35e8d96c in JOIN::optimize (this=this@entry=0x14562fc75c20) at /test/10.5_dbg/sql/sql_select.cc:1606
      #25 0x000055cd35e8e2f9 in mysql_select (thd=thd@entry=0x14562fc15088, tables=<optimized out>, fields=..., conds=0x14562fc75048, og_num=0, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14562fc75bf8, unit=0x14562fc190a0, select_lex=0x14562fc74160) at /test/10.5_dbg/sql/sql_select.cc:4655
      #26 0x000055cd35e8e675 in handle_select (thd=thd@entry=0x14562fc15088, lex=lex@entry=0x14562fc18fd8, result=result@entry=0x14562fc75bf8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:417
      #27 0x000055cd35e190bf in execute_sqlcom_select (thd=thd@entry=0x14562fc15088, all_tables=0x14562fc74758) at /test/10.5_dbg/sql/sql_parse.cc:6207
      #28 0x000055cd35e121f4 in mysql_execute_command (thd=thd@entry=0x14562fc15088) at /test/10.5_dbg/sql/sql_parse.cc:3939
      #29 0x000055cd35e1f02e in mysql_parse (thd=thd@entry=0x14562fc15088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x145652b613d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7991
      #30 0x000055cd35e0bb42 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14562fc15088, packet=packet@entry=0x14562fc67089 "SELECT * FROM t WHERE c='2010-00-01 00:00:00'", packet_length=packet_length@entry=45, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1874
      #31 0x000055cd35e0a31c in do_command (thd=0x14562fc15088) at /test/10.5_dbg/sql/sql_parse.cc:1355
      #32 0x000055cd35f6473f in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1456314453a8, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1411
      #33 0x000055cd35f64e5b in handle_one_connection (arg=arg@entry=0x1456314453a8) at /test/10.5_dbg/sql/sql_connect.cc:1313
      #34 0x000055cd363c414e in pfs_spawn_thread (arg=0x145650845888) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #35 0x0000145651f896db in start_thread (arg=0x145652b62700) at pthread_create.c:463
      #36 0x000014565138788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.4.14 (dbg), 10.5.4 (dbg)

      Bug confirmed not present in:
      MariaDB: 10.1.46 (dbg), 10.1.46 (opt), 10.2.33 (dbg), 10.2.33 (opt), 10.3.24 (dbg), 10.3.24 (opt), 10.4.14 (opt), 10.5.4 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: