Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-8221

MoreLikeThis.setMaxDocFreqPct can easily int-overflow on larger indexes

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.4
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

        public void setMaxDocFreqPct(int maxPercentage) {
          this.maxDocFreq = maxPercentage * ir.numDocs() / 100;
        }
      

      The above overflows integer range into negative numbers on even fairly small indexes (for maxPercentage = 75, it happens for just over 28 million documents.

      We should make the computations on long range so that it doesn't overflow and have a more strict argument validation.

        Attachments

        1. LUCENE-8221.patch
          3 kB
          Dawid Weiss

          Issue Links

            Activity

              People

              • Assignee:
                dweiss Dawid Weiss
                Reporter:
                dweiss Dawid Weiss
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: