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

empty input returns 0, contradicting the official xxHash test vectors

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • 13.1
    • N/A
    • Partitioning
    • None
    • Not for Release Notes

    Description

      An independent defect (NOT caused by the collation-sortkey root cause above — re-verified during audit: the empty string returns 0 under every collation, so the collation path is not involved). CONV(XXH3(''),10,16) returns 0 while the official xxHash vectors are XXH3_64bits("") = 0x2D06800538D394C2 and XXH32("") = 0x02CC5D05. Consequences: (a) values computed by any standard xxHash implementation (C/Python/xxhash CLI) never match MariaDB's, making the function unusable for cross-system hash verification; (b) the empty string and NULL are indistinguishable (both yield 0). Requires a separate fix from M11/M12 (likely an empty-input short-circuit or finalization bug in the Hasher wrapper).

      SELECT CONV(XXH3(''), 10, 16);   -- 0        official XXH3_64bits("") = 0x2D06800538D394C2
      SELECT CONV(XXH32(''), 10, 16);  -- 0        official XXH32("")      = 0x02CC5D05
      

      AI suggests fix:

      Change val_int() to byte semantics, same as Item_func_md5:

      String *res= args[0]->val_str(&buffer);
      if (!res)

      { null_value= 1; return 0; }

      hasher.update(res->ptr(), res->length());
      Also add regression tests from the official xxHash vectors (empty string / single byte / known vectors).

      Attachments

        Activity

          People

            Unassigned Unassigned
            chunlingqin chunlingqin
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.