JDK-5012260 : ArrayStore exception in java.util.IdentityHashMap.put causes VM crash
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-03-12
  • Updated: 2004-03-27
  • Resolved: 2004-03-27
Related Reports
Duplicate :  
Description

Name: tb29552			Date: 03/11/2004


FULL PRODUCT VERSION :
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b01)
Java HotSpot(TM) Client VM (build 1.4.2_03-b01, mixed mode)

java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)


FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
The bug is reproduced bith with JDK 1.4.2 and JDK 1.5.0

A DESCRIPTION OF THE PROBLEM :
I perform traversing of object tree started from specified roots and place visited objects in IdentityHashMap. When traversing java.lang.Class object, placing sun.reflect.UnsafeStaticFieldAccessorImpl object in IdentityHashMap cause ArrayStore exception.
If exception is catched and ignored, then
subsequent excecution of the program cause EXCEPTION_ACCESS_VIOLATION (0xc0000005).


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac IdentityBug.java

java IdentityBug

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
empty screen
ACTUAL -
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x806
4954
Function=[Unknown.]
Library=C:\j2sdk1.4.2_02\jre\bin\client\jvm.dll

NOTE: We are unable to locate the function name symbol for the error
      just occurred. Please refer to release documentation for possible
      reason and solutions.


Current Java thread:
        at java.lang.Class.getDeclaredFields0(Native Method)
        at java.lang.Class.privateGetDeclaredFields(Class.java:1514)
        at java.lang.Class.getDeclaredFields(Class.java:1090)
        at IdentityBug.traverse(IdentityBug.java:20)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:15)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:15)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:15)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverseClass(IdentityBug.java:43)
        at IdentityBug.main(IdentityBug.java:51)

Dynamic libraries:
0x00400000 - 0x00406000         C:\j2sdk1.4.2_02\bin\java.exe
0x77F50000 - 0x77FF7000         C:\WINDOWS\System32\ntdll.dll
0x77E60000 - 0x77F46000         C:\WINDOWS\system32\kernel32.dll
0x77DD0000 - 0x77E5D000         C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x78086000         C:\WINDOWS\system32\RPCRT4.dll
0x77C10000 - 0x77C63000         C:\WINDOWS\system32\MSVCRT.dll
0x08000000 - 0x08138000         C:\j2sdk1.4.2_02\jre\bin\client\jvm.dll
0x77D40000 - 0x77DCC000         C:\WINDOWS\system32\USER32.dll
0x77C70000 - 0x77CB0000         C:\WINDOWS\system32\GDI32.dll
0x76B40000 - 0x76B6C000         C:\WINDOWS\System32\WINMM.dll
0x10000000 - 0x10007000         C:\j2sdk1.4.2_02\jre\bin\hpi.dll
0x00390000 - 0x0039E000         C:\j2sdk1.4.2_02\jre\bin\verify.dll
0x003A0000 - 0x003B9000         C:\j2sdk1.4.2_02\jre\bin\java.dll
0x003C0000 - 0x003CD000         C:\j2sdk1.4.2_02\jre\bin\zip.dll
0x76C90000 - 0x76CB2000         C:\WINDOWS\system32\imagehlp.dll
0x6D510000 - 0x6D58D000         C:\WINDOWS\system32\DBGHELP.dll
0x77C00000 - 0x77C07000         C:\WINDOWS\system32\VERSION.dll
0x76BF0000 - 0x76BFB000         C:\WINDOWS\System32\PSAPI.DLL

Heap at VM Abort:
Heap
 def new generation   total 576K, used 347K [0x10010000, 0x100b0000, 0x104f0000)

  eden space 512K,  67% used [0x10010000, 0x10066dd0, 0x10090000)
  from space 64K,   0% used [0x10090000, 0x10090000, 0x100a0000)
  to   space 64K,   0% used [0x100a0000, 0x100a0000, 0x100b0000)
 tenured generation   total 1408K, used 0K [0x104f0000, 0x10650000, 0x14010000)
   the space 1408K,   0% used [0x104f0000, 0x104f0000, 0x104f0200, 0x10650000)
 compacting perm gen  total 4096K, used 1131K [0x14010000, 0x14410000, 0x1801000
0)
   the space 4096K,  27% used [0x14010000, 0x1412afe0, 0x1412b000, 0x14410000)

Local Time = Thu Mar 11 01:03:16 2004
Elapsed Time = 0
#
# HotSpot Virtual Machine Error : EXCEPTION_ACCESS_VIOLATION
# Error ID : 4F530E43505002EF
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_03-b01 mixed mode)
#
# An error report file has been saved as hs_err_pid976.log.
# Please refer to the file for further information.
#

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x806
4954
Function=[Unknown.]
Library=C:\j2sdk1.4.2_02\jre\bin\client\jvm.dll

NOTE: We are unable to locate the function name symbol for the error
      just occurred. Please refer to release documentation for possible
      reason and solutions.


Current Java thread:
        at java.lang.Class.getDeclaredFields0(Native Method)
        at java.lang.Class.privateGetDeclaredFields(Class.java:1514)
        at java.lang.Class.getDeclaredFields(Class.java:1090)
        at IdentityBug.traverse(IdentityBug.java:20)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:15)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:15)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:15)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverse(IdentityBug.java:26)
        at IdentityBug.traverseClass(IdentityBug.java:43)
        at IdentityBug.main(IdentityBug.java:51)

Dynamic libraries:
0x00400000 - 0x00406000         C:\j2sdk1.4.2_02\bin\java.exe
0x77F50000 - 0x77FF7000         C:\WINDOWS\System32\ntdll.dll
0x77E60000 - 0x77F46000         C:\WINDOWS\system32\kernel32.dll
0x77DD0000 - 0x77E5D000         C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x78086000         C:\WINDOWS\system32\RPCRT4.dll
0x77C10000 - 0x77C63000         C:\WINDOWS\system32\MSVCRT.dll
0x08000000 - 0x08138000         C:\j2sdk1.4.2_02\jre\bin\client\jvm.dll
0x77D40000 - 0x77DCC000         C:\WINDOWS\system32\USER32.dll
0x77C70000 - 0x77CB0000         C:\WINDOWS\system32\GDI32.dll
0x76B40000 - 0x76B6C000         C:\WINDOWS\System32\WINMM.dll
0x10000000 - 0x10007000         C:\j2sdk1.4.2_02\jre\bin\hpi.dll
0x00390000 - 0x0039E000         C:\j2sdk1.4.2_02\jre\bin\verify.dll
0x003A0000 - 0x003B9000         C:\j2sdk1.4.2_02\jre\bin\java.dll
0x003C0000 - 0x003CD000         C:\j2sdk1.4.2_02\jre\bin\zip.dll
0x76C90000 - 0x76CB2000         C:\WINDOWS\system32\imagehlp.dll
0x6D510000 - 0x6D58D000         C:\WINDOWS\system32\DBGHELP.dll
0x77C00000 - 0x77C07000         C:\WINDOWS\system32\VERSION.dll
0x76BF0000 - 0x76BFB000         C:\WINDOWS\System32\PSAPI.DLL

Heap at VM Abort:
Heap
 def new generation   total 576K, used 347K [0x10010000, 0x100b0000, 0x104f0000)

  eden space 512K,  67% used [0x10010000, 0x10066dd0, 0x10090000)
  from space 64K,   0% used [0x10090000, 0x10090000, 0x100a0000)
  to   space 64K,   0% used [0x100a0000, 0x100a0000, 0x100b0000)
 tenured generation   total 1408K, used 0K [0x104f0000, 0x10650000, 0x14010000)
   the space 1408K,   0% used [0x104f0000, 0x104f0000, 0x104f0200, 0x10650000)
 compacting perm gen  total 4096K, used 1131K [0x14010000, 0x14410000, 0x1801000
0)
   the space 4096K,  27% used [0x14010000, 0x1412afe0, 0x1412b000, 0x14410000)

Local Time = Thu Mar 11 01:03:16 2004
Elapsed Time = 0
#
# HotSpot Virtual Machine Error : EXCEPTION_ACCESS_VIOLATION
# Error ID : 4F530E43505002EF
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_03-b01 mixed mode)
#
# An error report file has been saved as hs_err_pid976.log.
# Please refer to the file for further information.
#

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.lang.reflect.*;
import java.util.*;

public class IdentityBug {
    static IdentityHashMap map = new IdentityHashMap();

    static void traverse(Object obj) throws Exception {
        if (obj != null && map.get(obj) == null) {
            try {
                map.put(obj, obj);
            } catch (Exception x) {}
            if (obj instanceof Object[]) {
                Object[] arr = (Object[])obj;
                for (int i = 0; i < arr.length; i++) {
                    traverse(arr[i]);
                }
            } else {
                Class cls = obj.getClass();
                do {
                    Field[] fields = cls.getDeclaredFields();
                    for (int i = 0; i < fields.length; i++) {
                        Field f = fields[i];
                        Class type = f.getType();
                        if (!type.isPrimitive()) {
                            f.setAccessible(true);
                            traverse(f.get(obj));
                        }
                    }
                } while ((cls = cls.getSuperclass()) != null);
            }
        }
    }

    static void traverseClass(Class cls) throws Exception {
        do {
            Field[] fields = cls.getDeclaredFields();
            for (int i = 0; i < fields.length; i++) {
                Field f = fields[i];
                if ((f.getModifiers() & Modifier.STATIC) != 0) {
                    Class type = f.getType();
                    if (!type.isPrimitive()) {
                        f.setAccessible(true);
                        traverse(f.get(null));
                    }
                }
            }
        } while ((cls = cls.getSuperclass()) != null);
    }

    public static void main(String[] arg) throws Exception {
        traverseClass(IdentityBug.class);
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Do not traverse java.lang.Class
(Incident Review ID: 242955) 
======================================================================

Comments
PUBLIC COMMENTS .
10-06-2004

EVALUATION This is the same issue as 5012949. Since that bug has more information in the evaluation and workaround sections I'm closing this one as a duplicate of that. ###@###.### 2004-03-26
26-03-2004