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

SIGSEGV optimizing HAVING DAYOFYEAR over a derived column from an empty table

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      How to repeat

      Execute the complete block below on an isolated MariaDB 12.3.2 instance with the optimizer settings listed above. It drops and recreates only `dayofyear_repro`. This is the exact independently replayed final SQL; no attachment or repository checkout is required.

      DROP DATABASE IF EXISTS dayofyear_repro;
       
      CREATE DATABASE dayofyear_repro;
       
      USE dayofyear_repro;
       
      CREATE TABLE t1 (c1 INT);
       
      SELECT 1
      FROM (SELECT '2000-1-1' AS d FROM t1) AS s JOIN t1 AS t ON TRUE
      GROUP BY t.c1, s.d
      HAVING DAYOFYEAR(s.d) = t.c1;
      

      Expected result

      Return an empty result set and keep the server running. `t1` has no rows, so neither the derived table nor the inner join can produce a group.

      Actual result

      The exact SQL above reproduced SIGSEGV in *3/3 consecutive trials* (`trial-009` through `trial-011`). Each trial recorded a new signal-11 fatal block, server exit code *139*, `OOMKilled=false`, and the shared temporal-function and optimizer frames. The client received:

      OperationalError: (2013, 'Lost connection to MySQL server during query')
      

      Relevant frames from the final reduced query, ordered from the fault toward the caller:

      Temporal_with_date::make_from_item + 0x70
      Item_func_dayofyear::val_int + 0x46
      Type_handler_int_result::Item_eq_value + 0x23
      Item_equal::add_const + 0x4e
      Item_equal::merge_with_check + 0xe1
      propagate_new_equalities + 0xd8
      and_new_conditions_to_optimized_cond + 0x71f
      JOIN::optimize_inner + 0x195f
      JOIN::optimize + 0xf3
      mysql_select
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              chen7897 cl hl
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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