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

Threads spinning infinitely in WeakHashMap.get running test262parallel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 9
    • core-libs
    • b56
    • generic
    • 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

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

                Dates

                  Created:
                  Updated:
                  Resolved: