Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319114

Summary: Concurrent access to non-thread safe WeakHashMap in org.aspectj.weaver.Dump causes infinite loops
Product: [Tools] AspectJ Reporter: Cándido Martínez Descalzo <candido.martinez>
Component: RuntimeAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: aclement, jon.seymour
Version: 1.6.9   
Target Milestone: 1.6.10   
Hardware: Sun   
OS: Solaris   
Whiteboard:

Description Cándido Martínez Descalzo CLA 2010-07-07 08:02:06 EDT
This bug seems to have the same root cause as bug 220686 and bug 269867.

The nodes map in org.aspectj.weaver.Dump is a non-thread safe WeakHashMap. On a multithreaded environment, concurrent access to this map can cause corruption and lead to infinite loops accessing it.

The solution for this problem should be similar to those for bugs 220686 and bug 269867, decorating the nodes WeakHashMap with Collections.synchronizedMap()

On a Weblogic 10.0 environment we are seeing many threads stuck while accessing the nodes map:

        java.util.WeakHashMap.put(WeakHashMap.java:397)
        org.aspectj.weaver.Dump.registerNode(Dump.java:247)
        org.aspectj.weaver.World.<init>(World.java:157)
        org.aspectj.weaver.reflect.ReflectionWorld.<init>(ReflectionWorld.java:54)
       org.aspectj.weaver.tools.PointcutParser.setClassLoader(PointcutParser.java:229)
        org.aspectj.weaver.reflect.InternalUseOnlyPointcutParser.<init>(InternalUseOnlyPointcutParser.java:23)
        org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getDeclaredPointcuts(Java15ReflectionBasedReferenceTypeDelegate.java:256)
        org.aspectj.weaver.ReferenceType.getDeclaredPointcuts(ReferenceType.java:538)
        org.aspectj.weaver.ResolvedType$7.get(ResolvedType.java:482)
        org.aspectj.weaver.Iterators$3$1.hasNext(Iterators.java:118)
        org.aspectj.weaver.Iterators$3.hasNext(Iterators.java:128)
        org.aspectj.weaver.ResolvedType.findPointcut(ResolvedType.java:493)
        org.aspectj.weaver.patterns.ReferencePointcut.resolveBindings(ReferencePointcut.java:152)
        org.aspectj.weaver.patterns.Pointcut.resolve(Pointcut.java:196)
        org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:332)
        org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:310)
Comment 1 Andrew Clement CLA 2010-07-07 12:00:52 EDT
Rather than synchronize, I'll think I'll just remove that map and any code using it.  In the last 5 years I have never used the dump output produced from the nodes map to debug a problem..
Comment 2 Andrew Clement CLA 2010-07-07 12:47:23 EDT
change is committed. should be in the next dev build
Comment 3 Andrew Clement CLA 2010-07-12 16:18:17 EDT
possibly gone a bit far with this now - although I never used the state that was in there, the exceptions have also gone, which were useful.
Comment 4 Andrew Clement CLA 2010-10-25 11:14:52 EDT
done what I need for 1.6.10
Comment 5 Andrew Clement CLA 2010-10-25 11:15:50 EDT
*** Bug 328558 has been marked as a duplicate of this bug. ***