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

fts query crashes in fts_query_calculate_ranking()

    XMLWordPrintable

Details

    Description

      Description:
      fts query crashes in fts_query_calculate_ranking().

      #0 0x00007f9d2b85b387 in raise () from /lib64/libc.so.6
      #1 0x00007f9d2b85ca78 in abort () from /lib64/libc.so.6
      #2 0x0000000001246471 in my_server_abort ()
      at sql/signal_handler.cc:303
      #3 0x0000000002233faa in my_abort ()
      at mysys/my_init.cc:258
      #4 0x000000000259ea5e in ut_dbg_assertion_failed (expr=expr@entry=0x30e5f02 "ret == 0",
      file=file@entry=0x38fcf38 "storage/innobase/fts/fts0que.cc", line=line@entry=3285)
      at storage/innobase/ut/ut0dbg.cc:99
      #5 0x0000000002783269 in fts_query_calculate_ranking (ranking=0x7f9c163c8150, query=0x7f9d1f92ca10)
      at storage/innobase/fts/fts0que.cc:3285
      #6 fts_query_prepare_result (result=0x7f9c162033a0, query=0x7f9d1f92ca10)
      at storage/innobase/fts/fts0que.cc:3436
      #7 fts_query_get_result (result=<optimized out>, query=0x7f9d1f92ca10)
      at storage/innobase/fts/fts0que.cc:3475
      #8 fts_query (trx=trx@entry=0x7f9d24202728, index=index@entry=0x7f9c21eac888, flags=flags@entry=9,
      query_str=query_str@entry=0x7f9c1623d2a0 "雪人", query_len=query_len@entry=6,
      result=result@entry=0x7f9d1f92ed60, limit=<optimized out>)
      at storage/innobase/fts/fts0que.cc:3793
      #9 0x00000000023bf647 in ha_innobase::ft_init_ext (this=0x7f9c1629fc30, flags=9, keynr=3, key=<optimized out>)
      at storage/innobase/handler/ha_innodb.cc:11267

      Suggested fix:
      The root cause is that compare function for rbtree is wrong.

      /** Compare two fts_ranking_t doc_ids.
      @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */
      static inline int fts_ranking_doc_id_cmp(const void p1, /!< in: id1 */
      const void p2) /!< in: id2 */
      {
      const fts_ranking_t *rk1 = (const fts_ranking_t *)p1;
      const fts_ranking_t *rk2 = (const fts_ranking_t *)p2;

      return ((int)(rk1->doc_id - rk2->doc_id)); --wrong!!!
      }

      It's totally wrong to compare two integers as below, no matter signed or
      unsigned.

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              shaohua.wang Shaohua Wang
              Votes:
              1 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.