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

Threads spinning infinitely in WeakHashMap.get running test262parallel

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b56
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        When running test262parallel, it sometimes hangs indefinitely. Looks like this happens because sometimes threads try to read the protoHistory of the same PropertyMap at the same time it is being modified, and this unfortunately can lead to an infinite loop in WeakHashMap due to the way it is written (it is not threadsafe):

        at java.util.WeakHashMap.get(WeakHashMap.java:403)
        at jdk.nashorn.internal.runtime.PropertyMap.checkProtoHistory(PropertyMap.java:687)
        at jdk.nashorn.internal.runtime.PropertyMap.changeProto(PropertyMap.java:886)
        at jdk.nashorn.internal.runtime.ScriptObject.setProto(ScriptObject.java:1288)
        ...

        It seems that in a multithreaded environment, PropertyMap.history and .protoHistory would need to be threadsafe. They're both caches with weak keys and soft values (WeakHashMap<K, SoftReference<V>>) and WeakHashMap is unfortunately not threadsafe.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hannesw Hannes Wallnoefer
                  Reporter:
                  attila Attila Szegedi
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: