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

Assertion `scale <= precision' fails in strings/decimal.c

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 10.0.2, 5.5.31, 5.3.13
    • None
    • None

    Description

      There are two similar test cases which end up with the same assertion failure and seemingly identical stack traces. However, for the test case #1 the failure is only reproducible on maria/5.5 and started happening from the revno 3696 (revision-id: sergii@pisem.net-20130313213352-mda1gh0dj1lyscc5); while for the test case #2 the failure is reproducible on all of maria/5.3 (revno 3635), maria/5.5 (revno 3699), maria/10.0 (revno 3503, failed assertion is 'scale >= 0 && precision > 0 && scale <= precision').

      I still presume they are related; if not, I can split the bugs into two.

      It might also be related to MDEV-4241.

      Test case #1:

      CREATE TABLE t1 (a INT) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (4),(8);
      SELECT DISTINCT 100 MOD TIMESTAMPADD( WEEK, a, '2002-05-20' ) FROM t1;

      mysqld: 5.5/strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed.
      [ERROR] mysqld got signal 6 ;

      #7  0x00007ff778600192 in __GI___assert_fail (assertion=0xf9a433 "scale <= precision", file=0xf9a1a0 "5.5/strings/decimal.c", line=1450, function=0xf9a620 "decimal_bin_size") at assert.c:103
      #8  0x0000000000ceca14 in decimal_bin_size (precision=25, scale=31) at 5.5/strings/decimal.c:1450
      #9  0x0000000000678f69 in my_decimal_get_binary_size (precision=25, scale=31) at 5.5/sql/my_decimal.h:263
      #10 0x000000000066fd1d in calc_group_buffer (join=0x7ff764008138, group=0x7ff764009430) at 5.5/sql/sql_select.cc:20326
      #11 0x000000000064114a in JOIN::optimize (this=0x7ff764008138) at 5.5/sql/sql_select.cc:1564
      #12 0x00000000006464cd in mysql_select (thd=0x286c5f0, rref_pointer_array=0x286f358, tables=0x7ff764007aa0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748609, result=0x7ff764008118, unit=0x286ea28, select_lex=0x286f100) at 5.5/sql/sql_select.cc:3048
      #13 0x000000000063d0d6 in handle_select (thd=0x286c5f0, lex=0x286e978, result=0x7ff764008118, setup_tables_done_option=0) at 5.5/sql/sql_select.cc:318
      #14 0x0000000000615fce in execute_sqlcom_select (thd=0x286c5f0, all_tables=0x7ff764007aa0) at 5.5/sql/sql_parse.cc:4641
      #15 0x000000000060ea81 in mysql_execute_command (thd=0x286c5f0) at 5.5/sql/sql_parse.cc:2195
      #16 0x0000000000618852 in mysql_parse (thd=0x286c5f0, rawbuf=0x7ff7640074c8 "SELECT DISTINCT 100 MOD TIMESTAMPADD( WEEK, a, '2002-05-20' ) FROM t1", length=69, parser_state=0x7ff76dce3500) at 5.5/sql/sql_parse.cc:5756
      #17 0x000000000060bff4 in dispatch_command (command=COM_QUERY, thd=0x286c5f0, packet=0x2961691 "SELECT DISTINCT 100 MOD TIMESTAMPADD( WEEK, a, '2002-05-20' ) FROM t1", packet_length=69) at 5.5/sql/sql_parse.cc:1068
      #18 0x000000000060b239 in do_command (thd=0x286c5f0) at 5.5/sql/sql_parse.cc:794
      #19 0x000000000070f816 in do_handle_one_connection (thd_arg=0x286c5f0) at 5.5/sql/sql_connect.cc:1266
      #20 0x000000000070f201 in handle_one_connection (arg=0x286c5f0) at 5.5/sql/sql_connect.cc:1181
      #21 0x0000000000a9bd40 in pfs_spawn_thread (arg=0x28ec1e0) at 5.5/storage/perfschema/pfs.cc:1015
      #22 0x00007ff7793d0e9a in start_thread (arg=0x7ff76dce4700) at pthread_create.c:308
      #23 0x00007ff7786c4cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      Stack trace from

      revision-id: sanja@askmonty.org-20130314170720-7qhmgzam5831ak30
      revno: 3699
      branch-nick: 5.5

      Result on 5.3:

      CREATE TABLE t1 (a INT) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (4),(8);
      SELECT DISTINCT 100 MOD TIMESTAMPADD( WEEK, a, '2002-05-20' ) FROM t1;
      100 MOD TIMESTAMPADD( WEEK, a, '2002-05-20' )
      100

      Test case #2:

      CREATE TABLE t1 (i INT) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (2),(4);
      SELECT DISTINCT CONVERT_TZ( '2001-03-21', 'GMT', 'EST' ) MOD i FROM t1;

      Stack trace on 5.3 (stack trace on 5.5 is like the above):

      #7  0x00007f944fd45192 in __GI___assert_fail (assertion=0xf25233 "scale <= precision", file=0xf24fc0 "decimal.c", line=1469, function=0xf25400 "decimal_bin_size") at assert.c:103
      #8  0x0000000000c24f16 in decimal_bin_size (precision=25, scale=31) at decimal.c:1469
      #9  0x00000000005aabac in my_decimal_get_binary_size (precision=25, scale=31) at my_decimal.h:236
      #10 0x000000000073edbb in calc_group_buffer (join=0x7f943402bbc8, group=0x7f943402cb78) at sql_select.cc:20022
      #11 0x000000000070f22e in JOIN::optimize (this=0x7f943402bbc8) at sql_select.cc:1498
      #12 0x0000000000714863 in mysql_select (thd=0x2baa4d0, rref_pointer_array=0x2bad238, tables=0x7f9434047a08, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147764737, result=0x7f9434048348, unit=0x2baca68, select_lex=0x2bacf90) at sql_select.cc:2976
      #13 0x000000000070b2a3 in handle_select (thd=0x2baa4d0, lex=0x2bac9c8, result=0x7f9434048348, setup_tables_done_option=0) at sql_select.cc:288
      #14 0x0000000000696737 in execute_sqlcom_select (thd=0x2baa4d0, all_tables=0x7f9434047a08) at sql_parse.cc:5172
      #15 0x000000000068d4f6 in mysql_execute_command (thd=0x2baa4d0) at sql_parse.cc:2305
      #16 0x00000000006991b1 in mysql_parse (thd=0x2baa4d0, rawbuf=0x7f9434045b38 "SELECT DISTINCT CONVERT_TZ( '2001-03-21', 'GMT', 'EST' ) MOD i FROM C", length=69, found_semicolon=0x7f944ebc87d8) at sql_parse.cc:6173
      #17 0x000000000068ac9a in dispatch_command (command=COM_QUERY, thd=0x2baa4d0, packet=0x2c35251 "SELECT DISTINCT CONVERT_TZ( '2001-03-21', 'GMT', 'EST' ) MOD i FROM C", packet_length=69) at sql_parse.cc:1243
      #18 0x0000000000689f38 in do_command (thd=0x2baa4d0) at sql_parse.cc:923
      #19 0x0000000000686993 in handle_one_connection (arg=0x2baa4d0) at sql_connect.cc:1231
      #20 0x00007f94508e0e9a in start_thread (arg=0x7f944ebc9700) at pthread_create.c:308
      #21 0x00007f944fe09cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      Attachments

        Activity

          People

            serg Sergei Golubchik
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.