Skip to content

com.ibm.wala.core.util.ref.ReferenceCleanser.clearSoftCaches() throws java.util.ConcurrentModificationException #1377

@khatchad

Description

@khatchad

From time to time, I am seeing the below failure:

java.util.ConcurrentModificationException
	at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:719)
	at java.base/java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:746)
	at com.ibm.wala.util.collections.MapIterator.next(MapIterator.java:34)
	at com.ibm.wala.core.util.ref.ReferenceCleanser.clearSoftCaches(ReferenceCleanser.java:77)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.unconditionallyAddConstraintsFromNode(SSAPropagationCallGraphBuilder.java:202)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.addConstraintsFromNode(SSAPropagationCallGraphBuilder.java:191)
	at com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder.addConstraintsFromNewNodes(PropagationCallGraphBuilder.java:308)
	at com.ibm.wala.ipa.callgraph.propagation.StandardSolver.solve(StandardSolver.java:53)
	at com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder.makeCallGraph(PropagationCallGraphBuilder.java:248)
	at com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder.makeCallGraph(PropagationCallGraphBuilder.java:191)
	at com.ibm.wala.cast.python.ml.test.TestTensorflow2Model.test(TestTensorflow2Model.java:1504)
	at com.ibm.wala.cast.python.ml.test.TestTensorflow2Model.testDataset31(TestTensorflow2Model.java:1059)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:398)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

I believe the iteration causing the problem is happening here:

The involved IClassHierarchy is coming from here:

https://github.com/wala/WALA/blob/45fa20ff0d31d72ff1c363ee153511a57da1b40e/core/src/main/java/com/ibm/wala/core/util/ref/ReferenceCleanser.java#L75C5-L75C20

Which is coming from here:

private static IClassHierarchy getClassHierarchy() {
IClassHierarchy result = null;
if (cha != null) {
result = cha.get();
}
return result;
}

The corresponding (static) field is here:

private static WeakReference<IClassHierarchy> cha;

Perhaps there needs to be some synchronization around this (static) field?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions