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

jdk/internal/util/ReferencedKeyTest.java can fail with ConcurrentModificationException

    XMLWordPrintable

Details

    • b11
    • aarch64
    • linux

    Backports

      Description

        We just started seeing this fail with Graal starting in jdk-24+5 when run with linux-aarch-debug with the arguments
        -Xcomp -ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:+TieredCompilation -XX:+VerifyOops -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler

        java.util.ConcurrentModificationException
        at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1721)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:727)
        at java.base/jdk.internal.util.ReferencedKeyMap.entrySet(ReferencedKeyMap.java:295)
        at java.base/jdk.internal.util.ReferencedKeyTest.methods(ReferencedKeyTest.java:101)
        at java.base/jdk.internal.util.ReferencedKeyTest.mapTest(ReferencedKeyTest.java:75)
        at java.base/jdk.internal.util.ReferencedKeyTest.main(ReferencedKeyTest.java:49)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
        at java.base/java.lang.Thread.run(Thread.java:1575)


        Looking at ReferencedKeyMap.entrySet:

            @Override
            public Set<Entry<K, V>> entrySet() {
                removeStaleReferences();
                return filterKeySet()
                        .map(k -> new AbstractMap.SimpleEntry<>(k, get(k)))
                        .collect(Collectors.toSet());
            }

        It seems to me that since the call to get(k) also calls removeStaleReferences(), a concurrent GC could trigger removal while building the set resulting in a ConcurrentModificationException. Shouldn't this method be calling map.get(k) directly instead? I'm unclear why it's failing with Graal though it might just be a timing a issue.

        Attachments

          Issue Links

            Activity

              People

                rriggs Roger Riggs
                never Tom Rodriguez
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: