Uploaded image for project: 'ORC'
  1. ORC
  2. ORC-1008

Overflow detection code is incorrect in IntegerColumnStatisticsImpl

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.0, 1.7.0
    • 1.7.1, 1.6.12
    • C++, Java
    • None

    Description

      void IntegerColumnStatisticsImpl::update(int64_t value, int repetitions) { 
         _stats.updateMinMax(value); 
        
         if (_stats.hasSum()) { 
           bool wasPositive = _stats.getSum() >= 0; 
           _stats.setSum(value * repetitions + _stats.getSum()); 
           if ((value >= 0) == wasPositive) { 
             _stats.setHasSum((_stats.getSum() >= 0) == wasPositive); 
           } 
         } 
       } 
      

      A counter-example can easily be given
      Assume sum=1, update(std::numeric_limits<int64_t>::max(), 3);
      value * repetitions + _stats.getSum() is overflowed, but is still a positive number : 9223372036854775806

      Attachments

        Issue Links

          Activity

            People

              Guiyankuang Yiqun Zhang
              Guiyankuang Yiqun Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: