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

Test main.execution_constants fails with memory exhausted near

Details

    Description

      After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in sql_parse.cc. It's very likely caused by optimized out the allocation of buf argument of the function, which is a stack variable in a caller frame.
      I'm suggesting the following patch:

      diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
      index a8e66d2a..9cbf23d7 100644
      --- a/sql/sql_parse.cc
      +++ b/sql/sql_parse.cc
      @@ -7229,10 +7229,14 @@ long max_stack_used;
           corresponding exec. (Thus we only have to check in fix_fields.)
         - Passing to check_stack_overrun() prevents the compiler from removing it.
       */
      -bool check_stack_overrun(THD *thd, long margin,
      -			 uchar *buf __attribute__((unused)))
      +bool check_stack_overrun(THD *thd, long margin, uchar *buf)
       {
         long stack_used;
      +  /*
      +     Take address of the buf argument in order to prevent
      +     the stack allocation made this function caller.
      +  */
      +  static volatile uchar *buf_ptr = buf;
         DBUG_ASSERT(thd == current_thd);
         if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
             (long) (my_thread_stack_size - margin))
      

      Attachments

        Activity

          marxin Martin Liška created issue -
          marxin Martin Liška made changes -
          Field Original Value New Value
          Description After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in `sql_parse.cc`. It's very likely caused by optimized out the allocation of `buf` argument of the function, which is a stack variable in a caller frame.
          I'm suggesting the following patch:

          ```patch
          diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
          index a8e66d2a..9cbf23d7 100644
          --- a/sql/sql_parse.cc
          +++ b/sql/sql_parse.cc
          @@ -7229,10 +7229,14 @@ long max_stack_used;
               corresponding exec. (Thus we only have to check in fix_fields.)
             - Passing to check_stack_overrun() prevents the compiler from removing it.
           */
          -bool check_stack_overrun(THD *thd, long margin,
          - uchar *buf __attribute__((unused)))
          +bool check_stack_overrun(THD *thd, long margin, uchar *buf)
           {
             long stack_used;
          + /*
          + Take address of the buf argument in order to prevent
          + the stack allocation made this function caller.
          + */
          + static volatile uchar *buf_ptr = buf;
             DBUG_ASSERT(thd == current_thd);
             if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
                 (long) (my_thread_stack_size - margin))
          ```
          After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in `sql_parse.cc`. It's very likely caused by optimized out the allocation of `buf` argument of the function, which is a stack variable in a caller frame.
          I'm suggesting the following patch:

          {{diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
          index a8e66d2a..9cbf23d7 100644
          --- a/sql/sql_parse.cc
          +++ b/sql/sql_parse.cc
          @@ -7229,10 +7229,14 @@ long max_stack_used;
               corresponding exec. (Thus we only have to check in fix_fields.)
             - Passing to check_stack_overrun() prevents the compiler from removing it.
           */
          -bool check_stack_overrun(THD *thd, long margin,
          - uchar *buf __attribute__((unused)))
          +bool check_stack_overrun(THD *thd, long margin, uchar *buf)
           {
             long stack_used;
          + /*
          + Take address of the buf argument in order to prevent
          + the stack allocation made this function caller.
          + */
          + static volatile uchar *buf_ptr = buf;
             DBUG_ASSERT(thd == current_thd);
             if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
                 (long) (my_thread_stack_size - margin))
          }}
          marxin Martin Liška made changes -
          Description After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in `sql_parse.cc`. It's very likely caused by optimized out the allocation of `buf` argument of the function, which is a stack variable in a caller frame.
          I'm suggesting the following patch:

          {{diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
          index a8e66d2a..9cbf23d7 100644
          --- a/sql/sql_parse.cc
          +++ b/sql/sql_parse.cc
          @@ -7229,10 +7229,14 @@ long max_stack_used;
               corresponding exec. (Thus we only have to check in fix_fields.)
             - Passing to check_stack_overrun() prevents the compiler from removing it.
           */
          -bool check_stack_overrun(THD *thd, long margin,
          - uchar *buf __attribute__((unused)))
          +bool check_stack_overrun(THD *thd, long margin, uchar *buf)
           {
             long stack_used;
          + /*
          + Take address of the buf argument in order to prevent
          + the stack allocation made this function caller.
          + */
          + static volatile uchar *buf_ptr = buf;
             DBUG_ASSERT(thd == current_thd);
             if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
                 (long) (my_thread_stack_size - margin))
          }}
          {{monospaced text}}After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in `sql_parse.cc`. It's very likely caused by optimized out the allocation of `buf` argument of the function, which is a stack variable in a caller frame.
          I'm suggesting the following patch:

          {{diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
          index a8e66d2a..9cbf23d7 100644
          --- a/sql/sql_parse.cc
          +++ b/sql/sql_parse.cc
          @@ -7229,10 +7229,14 @@ long max_stack_used;
               corresponding exec. (Thus we only have to check in fix_fields.)
             - Passing to check_stack_overrun() prevents the compiler from removing it.
           */
          -bool check_stack_overrun(THD *thd, long margin,
          - uchar *buf __attribute__((unused)))
          +bool check_stack_overrun(THD *thd, long margin, uchar *buf)
           {
             long stack_used;
          + /*
          + Take address of the buf argument in order to prevent
          + the stack allocation made this function caller.
          + */
          + static volatile uchar *buf_ptr = buf;
             DBUG_ASSERT(thd == current_thd);
             if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
                 (long) (my_thread_stack_size - margin))
          }}
          marxin Martin Liška made changes -
          Description {{monospaced text}}After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in `sql_parse.cc`. It's very likely caused by optimized out the allocation of `buf` argument of the function, which is a stack variable in a caller frame.
          I'm suggesting the following patch:

          {{diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
          index a8e66d2a..9cbf23d7 100644
          --- a/sql/sql_parse.cc
          +++ b/sql/sql_parse.cc
          @@ -7229,10 +7229,14 @@ long max_stack_used;
               corresponding exec. (Thus we only have to check in fix_fields.)
             - Passing to check_stack_overrun() prevents the compiler from removing it.
           */
          -bool check_stack_overrun(THD *thd, long margin,
          - uchar *buf __attribute__((unused)))
          +bool check_stack_overrun(THD *thd, long margin, uchar *buf)
           {
             long stack_used;
          + /*
          + Take address of the buf argument in order to prevent
          + the stack allocation made this function caller.
          + */
          + static volatile uchar *buf_ptr = buf;
             DBUG_ASSERT(thd == current_thd);
             if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
                 (long) (my_thread_stack_size - margin))
          }}
          After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in {{sql_parse.cc}}. It's very likely caused by optimized out the allocation of {{buf}} argument of the function, which is a stack variable in a caller frame.
          I'm suggesting the following patch:


          {code:java}
          diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
          index a8e66d2a..9cbf23d7 100644
          --- a/sql/sql_parse.cc
          +++ b/sql/sql_parse.cc
          @@ -7229,10 +7229,14 @@ long max_stack_used;
               corresponding exec. (Thus we only have to check in fix_fields.)
             - Passing to check_stack_overrun() prevents the compiler from removing it.
           */
          -bool check_stack_overrun(THD *thd, long margin,
          - uchar *buf __attribute__((unused)))
          +bool check_stack_overrun(THD *thd, long margin, uchar *buf)
           {
             long stack_used;
          + /*
          + Take address of the buf argument in order to prevent
          + the stack allocation made this function caller.
          + */
          + static volatile uchar *buf_ptr = buf;
             DBUG_ASSERT(thd == current_thd);
             if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
                 (long) (my_thread_stack_size - margin))
          {code}
          marxin Martin Liška made changes -
          Attachment mariadb_log.txt.bz2 [ 49624 ]
          elenst Elena Stepanova made changes -
          Component/s Server [ 13907 ]
          Fix Version/s 10.5 [ 23123 ]
          Affects Version/s 10.5 [ 23123 ]
          Assignee Sergey Vojtovich [ svoj ]
          Labels contribution
          serg Sergei Golubchik made changes -
          Assignee Sergey Vojtovich [ svoj ] Anel Husakovic [ anel ]
          anel Anel Husakovic made changes -
          Fix Version/s 10.5.1 [ 24029 ]
          Fix Version/s 10.5 [ 23123 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 101723 ] MariaDB v4 [ 157065 ]

          People

            anel Anel Husakovic
            marxin Martin Liška
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.