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

BucketCache causes ArithmeticException due to improper blockSize value checking

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      What happened

      There is no value checking for parameter hbase.blockcache.minblocksize. This may cause improper calculations and crashes the system like division by 0.

      Buggy code

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

        public BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
          int writerThreadNum, int writerQLen, String persistencePath, int ioErrorsTolerationDuration,
          Configuration conf) throws IOException {
          ...
          long blockNumCapacity = capacity / blockSize;
          ...

      How to reproduce

      (1) set hbase.blockcache.minblocksize=0
      (2) run org.apache.hadoop.hbase.io.hfile.TestCacheConfig#testBucketCacheConfigL1L2Setup

      you should observe the following failure:

      java.lang.ArithmeticException: / by zero
          at org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.<init>(BucketCache.java:282)
          at org.apache.hadoop.hbase.io.hfile.BlockCacheFactory.createBucketCache(BlockCacheFactory.java:238)
          at org.apache.hadoop.hbase.io.hfile.BlockCacheFactory.createBlockCache(BlockCacheFactory.java:110)
          at org.apache.hadoop.hbase.io.hfile.TestCacheConfig.testBucketCacheConfigL1L2Setup(TestCacheConfig.java:325)
              ...

      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. HBASE-27990.patch
          0.9 kB
          ConfX
        2. reproduce.sh
          0.7 kB
          ConfX

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: