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

ConcurrentHashMap.computeIfAbsent stuck in an endless loop

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • 9
    • 8, 8u25, 9
    • core-libs

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.8.0_25"
        Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
        Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Linux 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

        A DESCRIPTION OF THE PROBLEM :
        ConcurrentHashMap is stuck in an endless loop in computeIfAbsent - the for-loop starting at line 1649.

        tab=[
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null=null,
        null,
        null,
        null,
        null,
        class com.<redacted>.ClipboardPrepareImportService=com.<redacted>.ClipboardPrepareImportService@2ae00cd3,
        null,
        interface com.<redacted>.BackendConnectionGateway=Mock for BackendConnectionGateway, hashCode: 1117386246]

        h=833174808

        * the first if (line 1651) is skipped because tab is neither null nor empty
        * the second if as well because f = tabAt(....) is equal to null=null (CHM$ReservationNode)
        * the third if (line 1670) as well because fh = -3 (RESERVED)
        * we fall back into the else block at line 1672

        * tabAt(tab, i) == f is true (i=8) at line 1675
        * the if at line 1676 is not satisfied because fh = -3
        * the if at line 1696 is also not satisfied because f is an CHM$ReservationNode

        * binCount = 0 so the if at line 1710 is also not satisfied.

        Aaaand back to the beginning of the loop at 1649.


        The searched value is not yet present when computeIfPresent is called -> the mapper function should be called but that never happens.

        This only happens occasionally.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The mapping function is called and the computed value is added to the map and returned.
        ACTUAL -
        Endless loop.

        REPRODUCIBILITY :
        This bug can be reproduced occasionally.

        Attachments

          Issue Links

            Activity

              People

                martin Martin Buchholz
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: