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

Compress Result Metadata Uint32 Wrap

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      MariaDB 11.8.8
      Source revision: 46a8eb42a520193686d9a16d4cea4b3e002917e4

      sql/item_strfunc.h:2357-2366

        class Item_func_compress: public Item_str_binary_checksum_func
        {
          ...
          bool fix_length_and_dec(THD *thd) override
          {
            max_length= (args[0]->max_length * 120) / 100 + 12;
            return FALSE;
          }
      

      sql/item_strfunc.cc:4791-4849

      val_str() evaluates the actual argument, computes a runtime buffer from its
      actual length, prepends the four-byte original length, compresses into the
      buffer, and sets the String length from the actual compressed byte count.
      It does not use the wrapped metadata to truncate its direct result.

      Root cause: the producer metadata multiplication uses uint32 arithmetic before
      division and has no wide/saturating guard. Temporary/materialized consumers
      trust that too-small declaration.

      Current 11.8 revision d26f9ab217a7fcf9d4eccc62c01020ff275ff42e
      (11.8.9 development state) retains the exact expression at
      sql/item_strfunc.h:2365.

      Reproduce:
      timeout --signal=TERM --kill-after=15s 180s \
      bash novel/mariadb/compress-result-metadata-uint32-wrap/run_official.sh \
      "$PWD/repro-output/mariadb-compress-metadata" live1

      cat repro-output/mariadb-compress-metadata/status.tsv
      cat repro-output/mariadb-compress-metadata/query.stdout
      cat repro-output/mariadb-compress-metadata/query.stderr

      Attachments

        1. reproduce.sql
          2 kB
        2. run_official.sh
          2 kB
        3. mdev_40798.test
          1 kB

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              v3rdant Xingwang Xiang
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.