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

ReentrantReadWriteLock hang when used within ConcurrentHashMap::compute()

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      ADDITIONAL SYSTEM INFORMATION :
      $> java -version
      openjdk version "1.8.0_242"
      OpenJDK Runtime Environment (build 1.8.0_242-b08)
      OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

      $> cat /etc/redhat-release
      Red Hat Enterprise Linux Server release 7.3 (Maipo)

      $> uname -a
      Linux build 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Dec 28 14:23:39 EST 2017 x86_64 x86_64 x86_64 GNU/Linux

      $> grep processor /proc/cpuinfo
      processor : 0
      processor : 1
      processor : 2
      processor : 3

      $> cat /proc/meminfo | head -1
      MemTotal: 3864252 kB


      A DESCRIPTION OF THE PROBLEM :
      When using a ReentrantReadWriteLock with ConcurrentHashMap::compute() I get a deadlock with all threads waiting to grab a lock that no other thread seems to hold. This is occasionally seen with our product but I can always reproduce it with my small reproducer program.

      Reproduced on: 1.8.0_242 (I couldn't select it in the 'Java Release' drop down above)

      My reproducer is at https://github.com/rumpelstiltzkin/jdk_locking_bug and it includes a README and a runtest.sh script which spawns my reproducer application and brings it to a deadlocked state. Console output looks like this:
      $> ./runtest.sh
      seed is 1580458494008
      Main spawning 100 readers
      Main spawned 100 readers
      Main spawning a writer
      Main spawned a writer
      Main waiting for threads ...
      cache size is 204233
      cache size is 403273
      cache size is 617299
      cache size is 853090
      cache size is 1077020
      evicting 77020 entries
      evicted
      cache size is 1017003
      evicting 17003 entries
      evicted
      cache size is 1100766
      evicting 100766 entries
      evicted <=================== hung here


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Clone my github repo https://github.com/rumpelstiltzkin/jdk_locking_bug
      2. mvn clean install
      3. ./runtest.sh
      4. wait for it to stop printing to the console
      5. get the pid of the java program (ps -ef |grep java |grep -v grep)
      6. jstack -l pid > jstack.1. See evidence in jstack.1 that all threads are blocked on a lock that no thread holds.
      7. wait for a little while and then jstack -l pid > jstack.2
      8. diff jstack.1 jstack.2 to notice no difference.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Program should continue without deadlocks.
      ACTUAL -
      A deadlock.

      ---------- BEGIN SOURCE ----------
      https://github.com/rumpelstiltzkin/jdk_locking_bug
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None.

      FREQUENCY : always

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              pnarayanaswa Praveen Narayanaswamy
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: