Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8234127

BasicHashtable does not support small table_size

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b24

      Description

      I ran into this bug when trying to use KVHashtable. Simple repro is to build fastdebug JDK with a patch like this:

      diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
      --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
      +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
      @@ -1855,6 +1855,9 @@ jint G1CollectedHeap::initialize() {
       
         _collection_set.initialize(max_regions());
       
      + KVHashtable<size_t, size_t, mtGC> kv_map(1);
      + kv_map.add(42, 42);
      +
         return JNI_OK;
       }

      Then it fails with:
      # Internal Error (usr/local/google/home/manc/ws/jdkHeadOpen1/src/hotspot/share/utilities/hashtable.cpp:67), pid=73195, tid=73249
      # Error: assert(len >= _entry_size) failed

      The root cause is missing a minimum bound to compute block_size in BasicHashtableEntry<F>* BasicHashtable<F>::new_entry(unsigned int hashValue). The minimum bound has to be 2 in order to accommodate rounding down len to power of 2.

        Attachments

          Activity

            People

            • Assignee:
              manc Man Cao
              Reporter:
              manc Man Cao
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: