Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-28104 Improving checking and failure handling for configuration-exercised code
  3. HBASE-27989

ByteBuffAllocator causes ArithmeticException due to improper poolBufSize value checking

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      What happened

      There is no value checking for parameter hbase.server.allocator.buffer.size. This may cause improper calculations and crashes the system like division by 0.

      Buggy code

      In ByteBuffAllocator.java, there is no value checking for poolBufSize and this variable is directly used to calculate the bufsForTwoMB. When poolBufSize is mistakenly set to 0, the code would cause division by 0 and throw ArithmeticException to crash the system.

      public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnabled) {
          int poolBufSize = conf.getInt(BUFFER_SIZE_KEY, DEFAULT_BUFFER_SIZE);
          if (reservoirEnabled) {
          . . .
          int bufsForTwoMB = (2 * 1024 * 1024) / poolBufSize;
          . . .

      How to reproduce

      1. set hbase.server.allocator.buffer.size=0
        run
      2.  org.apache.hadoop.hbase.io.hfile.bucket.TestBucketCacheRefCnt#testInBucketCache
      3. you should observe the following failure:
      java.lang.ArithmeticException: / by zero
          at org.apache.hadoop.hbase.io.ByteBuffAllocator.create(ByteBuffAllocator.java:174)
          at org.apache.hadoop.hbase.io.hfile.bucket.TestBucketCacheRefCnt.testInBucketCache(TestBucketCacheRefCnt.java:224)
          . . .

      For an easy reproduction, run the reproduce.sh in the attachment. We are happy to provide a patch if this issue is confirmed.

      Attachments

        1. reproduce.sh
          0.7 kB
          ConfX

        Issue Links

          Activity

            People

              FuzzingTeam ConfX
              FuzzingTeam ConfX
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: