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

Bug in the logic of ConcurrentHashMap.addCount() when used in Threads

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      At java.util.concurrent.ConcurrentHashMap#addCount:2339
      i think the condition is if the thread is reach maximum or the new table size is twice as before or the nextTable is null or the transferIndex is lesss than zero; the bug in jdk8 is "https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8214427" , i think the main thing is not one is positive another is negtive, but the new table size is twice as before.
      at jdk12 i think is not fix it, "sc == rs + 1" compare the work thread but not array size, i think the code should be

      if (sc == rs + MAX_RESIZERS || (sc >>>RESIZE_STAMP_SHIFT) == (rs>>>RESIZE_STAMP_SHIFT) + 1 ||
                              (nt = nextTable) == null || transferIndex <= 0)
                              break;
      rather than

      if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
                              sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
                              transferIndex <= 0)
                              break;

      REGRESSION : Last worked in version 8


      FREQUENCY : always


            dl Doug Lea
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: