JDK-5086611 : Reading of JarEntry results in Hotspot error instead of throwing Java Exception
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 5.0,6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_8,solaris_9
  • CPU: generic,sparc
  • Submitted: 2004-08-13
  • Updated: 2010-05-14
  • Resolved: 2010-05-14
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The following steps of getting a Jar entry results in Hotspot VM error instead
of an Exception being thrown.

Way to reproduce the problem:

1. Create a JarFile instance using any Jar file
2. Get a Jar entry

// This is a programming error.
3. open the same Jar file for writing

4. Get a Jar entry again

I encountered this problem while working on an open source project (http://sourceforge.net/diduce) in a much more complex environment.

The following a code snippet reproduces the problem using the
jar file attached to this bug report.

import java.util.zip.*;
import java.util.jar.*;
import java.io.*;

class TestGetEntry {

    public static void main(String args[]) throws Exception {
         String jar_file_name = "java-classes.jar";
         String entry1 = "Methods.class";
         String entry2 = "Sanity.class";

         JarFile _input_jarfile = new JarFile (jar_file_name);
         JarEntry je = _input_jarfile.getJarEntry(entry1);
         System.out.println("entry name1:" + je.getName());

         FileOutputStream fos = new FileOutputStream(jar_file_name);
         JarOutputStream jout = new JarOutputStream(fos);

         je = _input_jarfile.getJarEntry (entry2);
         System.out.println("entry name2:" + je.getName());
    }
}

Note: the problem is reproduceable on 1.4.1, 1.4.2 as well as tiger b62.

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

======================================================================

Output:

entry name1:Methods.class
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGBUS (0xa) at pc=0xfe772ee8, pid=5530, tid=1
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0-beta3-b62 mixed mode)
# Problematic frame:
# C  [libzip.so+0x2ee8]
#
# An error report file with more information is saved as hs_err_pid5530.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

===========================================================================

The Error log is more verbose with 1.4.2 vm

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

Output:

entry name1:Methods.class

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : 10 occurred at PC=0xFE772DA0
Function=[Unknown. Nearest: ZIP_Lock+0x4C]
Library=/usr/dist/share/java,v1.4.2/5.x-sun4/jre/lib/sparc/libzip.so

Current Java thread:
        at java.util.zip.ZipFile.getEntry(Native Method)
        at java.util.zip.ZipFile.getEntry(ZipFile.java:146)
        - locked <0xf1432908> (a java.util.jar.JarFile)
        at java.util.jar.JarFile.getEntry(JarFile.java:194)
        at java.util.jar.JarFile.getJarEntry(JarFile.java:181)
        at TestGetEntry.main(TestGetEntry.java:21)

Dynamic libraries:
0x10000         /net/sqindia/export/disk05/jaya/java/re/jdk/1.4.2/latest/binaries/solaris-sparc/bin/java
0xff350000      /usr/lib/libthread.so.1
0xff390000      /usr/lib/libdl.so.1
0xff200000      /usr/lib/libc.so.1
0xff330000      /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
0xfe000000      /usr/dist/share/java,v1.4.2/5.x-sun4/jre/lib/sparc/client/libjvm.so
0xff2d0000      /usr/lib/libCrun.so.1
0xff1d0000      /usr/lib/libsocket.so.1
0xff100000      /usr/lib/libnsl.so.1
0xff0d0000      /usr/lib/libm.so.1
0xff0b0000      /usr/lib/libsched.so.1
0xff300000      /usr/lib/libw.so.1
0xff090000      /usr/lib/libmp.so.2
0xff050000      /usr/dist/share/java,v1.4.2/5.x-sun4/jre/lib/sparc/native_threads/libhpi.so
0xfe7d0000      /usr/dist/share/java,v1.4.2/5.x-sun4/jre/lib/sparc/libverify.so
0xfe790000      /usr/dist/share/java,v1.4.2/5.x-sun4/jre/lib/sparc/libjava.so
0xfe770000      /usr/dist/share/java,v1.4.2/5.x-sun4/jre/lib/sparc/libzip.so

Heap at VM Abort:
Heap
 def new generation   total 2112K, used 206K [0xf1400000, 0xf1620000, 0xf1b10000)
  eden space 2048K,  10% used [0xf1400000, 0xf1433af0, 0xf1600000)
  from space 64K,   0% used [0xf1600000, 0xf1600000, 0xf1610000)
  to   space 64K,   0% used [0xf1610000, 0xf1610000, 0xf1620000)
 tenured generation   total 1408K, used 0K [0xf1b10000, 0xf1c70000, 0xf5400000)
   the space 1408K,   0% used [0xf1b10000, 0xf1b10000, 0xf1b10200, 0xf1c70000)
 compacting perm gen  total 4096K, used 1058K [0xf5400000, 0xf5800000, 0xf9400000)
   the space 4096K,  25% used [0xf5400000, 0xf55088e0, 0xf5508a00, 0xf5800000)

Local Time = Fri Aug 13 13:05:23 2004
Elapsed Time = 7
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2-b28 mixed mode)
#
# An error report file has been saved as hs_err_pid5539.log.
# Please refer to the file for further information.
#

======================================================================

Comments
EVALUATION Can avoid the mmap crash if you override the jar file. see #6929479
14-05-2010

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
14-08-2004

PUBLIC COMMENTS -
14-08-2004

EVALUATION The analagous case where the zip file is not merely being read by Java code, but is actually on the classpath, is discussed in 4425695: Updating jar files crashes running programs It certainly would be nice to downgrade the JVM crash into an IOException, but this is hard to do while maintaining performance. I can't think of any way to implement the desirable behavior while continuing to use mmap. ###@###.### 2004-08-13
13-08-2004