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

Bitmap<128>::merge etc may crash on older GCC versions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.4
    • Fix Version/s: 10.4.6
    • Component/s: Compiling
    • Labels:
      None

      Description

      Older GCC incorrectly optimizes Bitmap<128> code by using SSE instructions on unaligned data.
      Analysis, by Vladislav Lesin

      The compiller error was found on Ubuntu 16.04, CentOS 6/7.
      To optimize the work with Bitmap<128>::buffer[] compiller uses sse instructions.
      For example, the following C++ code:

      -------------
      void intersect(Bitmap & map2)

      { for (uint i = 0; i < array_elements(buffer); i++) buffer[i] &= map2.buffer[i]; }

      -------------

      is compilled into the following instructions:

      -------------
      movdqu xmm0,XMMWORD PTR [r12+0x28]
      pand xmm0,XMMWORD PTR [rbx+0x28]
      -------------

      The second operand of 'pand' instruction must be alligned to 16, otherwise
      exception occurs. But compiller generates the above instruction with
      non-alligned second argument:

      --------------
      p ($rbx+0x28)%16
      $20 = 8
      --------------

      There were also other instructions with non-alligned memory operand, for
      example, 'por'.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              wlad Vladislav Vaintroub
              Reporter:
              wlad Vladislav Vaintroub
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: