JDK-6895383 : JCK test throws NPE for method compiled with Escape Analysis
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs17
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris
  • CPU: x86
  • Submitted: 2009-10-26
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u21Fixed 7Fixed hs17Fixed
Related Reports
Relates :  
Description
It seems that the following JCK test:
api/java_util/concurrent/CopyOnWriteArrayList/index.html#CopyOnWriteArrayList[testAddAll1_IndexOutOfBoundsException]
also fails due to the issue.

The minimized test throws NPE at line marked (*) with -Xcomp specified since JDK b72:
-----------------------------------------------------------
import java.util.*;
import java.util.concurrent.*;

public class CopyOnWriteArrayListTest {
    public static void main(String argv[]) {
        CopyOnWriteArrayListTest test = new CopyOnWriteArrayListTest();
        test.testRemove1_IndexOutOfBounds();
        test.testAddAll1_IndexOutOfBoundsException();
    }

    public void testRemove1_IndexOutOfBounds() {
        CopyOnWriteArrayList c = new CopyOnWriteArrayList();
    }

    public void testAddAll1_IndexOutOfBoundsException() {
        try {
            CopyOnWriteArrayList c = new CopyOnWriteArrayList();
            c.addAll(-1, new LinkedList()); // (*)
        } catch (IndexOutOfBoundsException e) {
        }
    }
}
-----------------------------------------------------------
*** (#3 of 3): 2009-10-26 10:12:14 PDT ###@###.###

Comments
WORK AROUND -XX:-DoEscapeAnalysis
11-12-2009

PUBLIC COMMENTS Problem: EA misses checks for MemBar nodes when looking for following MergeMem nodes. As result it did not add memory slice for the volatile store (followed by several MemBar nodes) in MergeMem of uncommon trap. So when the method deoptimized and eliminated object reallocated the NULL is stored to the corresponding field. Solution: Collect all MergeMem nodes at the beginning of EA when it walks through Ideal graph instead of searching MergeMem nodes by going down trough memory during memory splitting for non escaping objects. Also check for general MemBar nodes instead of only Initialize nodes during memory splitting. I also did next optimizations/fixes: 1. Check for SafePointScalarObject nodes to avoid printing empty lines in PrintOptoAssembly output since they don't have corresponding mach nodes. 2. Eliminate volatile MemBars nodes for stores into a scalar replaced objects. I noticed that we still generate membars even if the object is eliminated. For that I added the Precedent edge to corresponding Store node. 3. The check for ClearArray node is missing when searching for a better memory edge during EA, memory optimization and an object scalar replacement. We can't bypass it since it is the part of object initialization (zeroing). 4. Add missing checks for string intrinsic nodes to adjust the escape state (non scalar replaceable) of char[] arrays they use. 5. Move code for searching objects which are not scalar replaceable to separate method verify_escape_state() since the code became too large. Add a simple control flow check to find initializing store for oop fields. 6. Added asserts to check cases which don't have to be handled. 7. I also changed instance type setting for sequential CheckCastPP nodes to change following CheckCastPP node type to allocation type if it is subtype. 8. And I found that G1 barriers CallLeaf node case is missing in process_call_arguments() (as result referenced allocations were marked as global escape instead of thread local).
11-12-2009

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/f96a1a986f7b
10-12-2009

SUGGESTED FIX -XX:-DoEscapeAnalysis
19-11-2009

EVALUATION It is different from 6894807. It is caused by EA lost the array allocation for CopyOnWriteArrayList (the "array" field should not be NULL): 027 CALL,static wrapper for: uncommon_trap(reason='unloaded' action='reinterpret' index='8') # CopyOnWriteArrayListTest::testAddAll1_IndexOutOfBoundsException @ bci:10 L[0]=_ L[1]=_ STK[0]=#ScObj0 STK[1]=#-1 # ScObj0 java/util/concurrent/CopyOnWriteArrayList={ [lock :0]=#ScObj1, [array :1]=#NULL } # ScObj1 java/util/concurrent/locks/ReentrantLock={ [sync :0]=#ScObj2 } # ScObj2 java/util/concurrent/locks/ReentrantLock$NonfairSync={ [exclusiveOwnerThread :0]=#NULL, [state :1]=#0, [head :2]=#NULL, [tail :3]=#NULL } # OopMap{off=44}
26-10-2009