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

LP:998340 - Valgrind complains on simple selects containing expression DAY(FROM_UNIXTIME(-1))

Details

    • Bug
    • Status: Closed (View Workflow)
    • Trivial
    • Resolution: Fixed
    • 5.2.12, 5.1.62
    • 5.1.67, 5.2.14
    • None

    Description

      The following test case makes valgrind complain when running mariadb-5.1:

      SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
      SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
      SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
      SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
      SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
      SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
       
      CREATE TABLE t1
      SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1))) AS f1,
             LEFT('1', DAY(FROM_UNIXTIME(-1))) AS f2,
             RIGHT('1', DAY(FROM_UNIXTIME(-1))) AS f3,
             REPEAT('1', DAY(FROM_UNIXTIME(-1))) AS f4,
             RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f5,
             LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f6;
      SHOW CREATE TABLE t1;
      DROP TABLE t1;

      (see also bug##12634989 from mysql-trunk)

      The complains are like this:

      ==24162== Conditional jump or move depends on uninitialised value(s)
      ==24162==    at 0x622A1A: Item_func_substr::fix_length_and_dec() (item_strfunc.cc:1273)
      ==24162==    by 0x5EF4B7: Item_func::fix_fields(THD*, Item**) (item_func.cc:205)
      ==24162==    by 0x61E3DA: Item_str_func::fix_fields(THD*, Item**) (item_strfunc.cc:67)
      ==24162==    by 0x70BE1B: setup_fields(THD*, Item**, List<Item>&, enum_mark_columns, List<Item>*, bool) (sql_base.cc:7714)
      ==24162==    by 0x71F07B: JOIN::prepare(Item***, TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) (sql_select.cc:530)
      ==24162==    by 0x7268A7: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2545)
      ==24162==    by 0x71E818: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:280)
      ==24162==    by 0x6BD119: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5241)
      ==24162==    by 0x6B4232: mysql_execute_command(THD*) (sql_parse.cc:2380)
      ==24162==    by 0x6BF845: mysql_parse(THD*, char*, unsigned int, char const**) (sql_parse.cc:6216)
      ==24162==    by 0x6B1B30: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1294)
      ==24162==    by 0x6B0AE0: do_command(THD*) (sql_parse.cc:906)
      ==24162==    by 0x6AD563: handle_one_connection (sql_connect.cc:1208)
      ==24162==    by 0x5D16A4E: start_thread (in /lib64/libpthread-2.11.2.so)

      Most probably we have the same problem in other versions of MariaDB

      Attachments

        Activity

          igor Igor Babaev (Inactive) created issue -

          Launchpad bug id: 998340

          ratzpo Rasmus Johansson (Inactive) added a comment - Launchpad bug id: 998340
          ratzpo Rasmus Johansson (Inactive) made changes -
          Field Original Value New Value
          Labels Launchpad
          ratzpo Rasmus Johansson (Inactive) made changes -
          Key IMT-7762 MDEV-759
          Project ImportTest [ 10200 ] MariaDB Development [ 10000 ]
          Workflow jira [ 21411 ] defaullt [ 21603 ]
          elenst Elena Stepanova made changes -
          Affects Version/s 5.1.62 [ 10701 ]
          Affects Version/s 5.2.12 [ 10702 ]
          elenst Elena Stepanova made changes -
          Fix Version/s 5.2.13 [ 10800 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.2.14 [ 12101 ]
          Fix Version/s 5.2.13 [ 10800 ]
          serg Sergei Golubchik made changes -
          Description The following test case makes valgrind complain when running mariadb-5.1:

          SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
          SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
          SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
          SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
          SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
          SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');

          CREATE TABLE t1
          SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1))) AS f1,
                 LEFT('1', DAY(FROM_UNIXTIME(-1))) AS f2,
                 RIGHT('1', DAY(FROM_UNIXTIME(-1))) AS f3,
                 REPEAT('1', DAY(FROM_UNIXTIME(-1))) AS f4,
                 RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f5,
                 LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f6;
          SHOW CREATE TABLE t1;
          DROP TABLE t1;

          (see also bug##12634989 from mysql-trunk)

          The complains are like this:

          ==24162== Conditional jump or move depends on uninitialised value(s)
          ==24162== at 0x622A1A: Item_func_substr::fix_length_and_dec() (item_strfunc.cc:1273)
          ==24162== by 0x5EF4B7: Item_func::fix_fields(THD*, Item**) (item_func.cc:205)
          ==24162== by 0x61E3DA: Item_str_func::fix_fields(THD*, Item**) (item_strfunc.cc:67)
          ==24162== by 0x70BE1B: setup_fields(THD*, Item**, List<Item>&, enum_mark_columns, List<Item>*, bool) (sql_base.cc:7714)
          ==24162== by 0x71F07B: JOIN::prepare(Item***, TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) (sql_select.cc:530)
          ==24162== by 0x7268A7: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2545)
          ==24162== by 0x71E818: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:280)
          ==24162== by 0x6BD119: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5241)
          ==24162== by 0x6B4232: mysql_execute_command(THD*) (sql_parse.cc:2380)
          ==24162== by 0x6BF845: mysql_parse(THD*, char*, unsigned int, char const**) (sql_parse.cc:6216)
          ==24162== by 0x6B1B30: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1294)
          ==24162== by 0x6B0AE0: do_command(THD*) (sql_parse.cc:906)
          ==24162== by 0x6AD563: handle_one_connection (sql_connect.cc:1208)
          ==24162== by 0x5D16A4E: start_thread (in /lib64/libpthread-2.11.2.so)

          Most probably we have the same problem in other versions of MariaDB
          The following test case makes valgrind complain when running mariadb-5.1:
          {code:sql}
          SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
          SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
          SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
          SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
          SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
          SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');

          CREATE TABLE t1
          SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1))) AS f1,
                 LEFT('1', DAY(FROM_UNIXTIME(-1))) AS f2,
                 RIGHT('1', DAY(FROM_UNIXTIME(-1))) AS f3,
                 REPEAT('1', DAY(FROM_UNIXTIME(-1))) AS f4,
                 RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f5,
                 LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f6;
          SHOW CREATE TABLE t1;
          DROP TABLE t1;
          {code}
          (see also bug##12634989 from mysql-trunk)

          The complains are like this:
          {noformat}
          ==24162== Conditional jump or move depends on uninitialised value(s)
          ==24162== at 0x622A1A: Item_func_substr::fix_length_and_dec() (item_strfunc.cc:1273)
          ==24162== by 0x5EF4B7: Item_func::fix_fields(THD*, Item**) (item_func.cc:205)
          ==24162== by 0x61E3DA: Item_str_func::fix_fields(THD*, Item**) (item_strfunc.cc:67)
          ==24162== by 0x70BE1B: setup_fields(THD*, Item**, List<Item>&, enum_mark_columns, List<Item>*, bool) (sql_base.cc:7714)
          ==24162== by 0x71F07B: JOIN::prepare(Item***, TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) (sql_select.cc:530)
          ==24162== by 0x7268A7: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2545)
          ==24162== by 0x71E818: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:280)
          ==24162== by 0x6BD119: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5241)
          ==24162== by 0x6B4232: mysql_execute_command(THD*) (sql_parse.cc:2380)
          ==24162== by 0x6BF845: mysql_parse(THD*, char*, unsigned int, char const**) (sql_parse.cc:6216)
          ==24162== by 0x6B1B30: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1294)
          ==24162== by 0x6B0AE0: do_command(THD*) (sql_parse.cc:906)
          ==24162== by 0x6AD563: handle_one_connection (sql_connect.cc:1208)
          ==24162== by 0x5D16A4E: start_thread (in /lib64/libpthread-2.11.2.so)
          {noformat}
          Most probably we have the same problem in other versions of MariaDB

          Elena, could you please check whether it applies to 5.3+ ?

          serg Sergei Golubchik added a comment - Elena, could you please check whether it applies to 5.3+ ?
          serg Sergei Golubchik made changes -
          Assignee Alexey Botchkov [ holyfoot ] Elena Stepanova [ elenst ]

          Could not reproduce it on current MariaDB 5.3, 5.5, 10.0-base.
          Still reproducible on 5.2 (revno 3194).

          On 5.3 tried compile-pentium-valgrind-max-no-ndb and the provided test case with different values of optimizer_switch (in case it matters): default, all OFF values, and optimizer_switch from 5.2, no valgrind warnings with either.

          elenst Elena Stepanova added a comment - Could not reproduce it on current MariaDB 5.3, 5.5, 10.0-base. Still reproducible on 5.2 (revno 3194). On 5.3 tried compile-pentium-valgrind-max-no-ndb and the provided test case with different values of optimizer_switch (in case it matters): default, all OFF values, and optimizer_switch from 5.2, no valgrind warnings with either.
          elenst Elena Stepanova made changes -
          Assignee Elena Stepanova [ elenst ] Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Priority Major [ 3 ] Trivial [ 5 ]
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.1.67 [ 12100 ]

          pushed in 5.1

          serg Sergei Golubchik added a comment - pushed in 5.1
          serg Sergei Golubchik made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 21603 ] MariaDB v2 [ 46449 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 46449 ] MariaDB v3 [ 67153 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 67153 ] MariaDB v4 [ 146148 ]

          People

            serg Sergei Golubchik
            igor Igor Babaev (Inactive)
            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.