Uploaded image for project: 'Hadoop Map/Reduce'
  1. Hadoop Map/Reduce
  2. MAPREDUCE-7346

[Gridmix] A potential divide by zero in AvgRecordFactory

    XMLWordPrintableJSON

Details

    Description

      In the file gridmix/AvgRecordFactory.java, one of the class's constructor has the following code:

      public AvgRecordFactory(long targetBytes, long targetRecords,
            Configuration conf, int minSpilledBytes) {
          this.targetBytes = targetBytes;
          this.targetRecords = targetRecords <= 0 && this.targetBytes >= 0
            ? Math.max(1,
                this.targetBytes / conf.getInt(GRIDMIX_MISSING_REC_SIZE, 64 * 1024))
            : targetRecords;
          final long tmp = this.targetBytes / this.targetRecords;
          ...
      }
      

      The check in the code targetRecords <= 0 && this.targetBytes >= 0 is not sufficient: when targetRecords == 0 && targetBytes < 0, we can bypass the protection checking and set this.targetRecords to zero, leading to a divide by zero problem when computing tmp.

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Yiyuan GUO Yiyuan GUO
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h