harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Svetlana Samoilenko (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-89) java.util.jar.Manifest().read(InputStream is) throws OutOfMemoryError
Date Mon, 13 Feb 2006 11:17:42 GMT
java.util.jar.Manifest().read(InputStream is) throws OutOfMemoryError
---------------------------------------------------------------------

         Key: HARMONY-89
         URL: http://issues.apache.org/jira/browse/HARMONY-89
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Svetlana Samoilenko


Synopsis: java.util.jar.Manifest().read(InputStream is) throws OutOfMemoryError 

Description: For test listed below BEA throws IOException while Harmony throws OutOfMemoryError.


The test creates an instance of InputStreamImpl  where read method is implemented in simple
way and returned any integer value, in particular in.available()== 0 and  in.read(buf) ==
buf.length.
There is no checking for this conditions  in the InitManifest.readLines method  and as a result
an endless loop occurs.
Suggested fix in attachment may be incomplete, needs additional investigation.

Code to reproduce: 
import java.util.jar.*; 
import java.io.*; 
 
public class test2 { 
    public static void main(String args[]) { 
        InputStream is = new InputStreamImpl(); 
    try { 
        new Manifest().read(is); 
    } catch (IOException e) { 
         e.printStackTrace(); 
         System.out.println("PASSED"); 
    }     
  } 
}

class InputStreamImpl extends InputStream{        
        public InputStreamImpl() { 
                super(); 
        } 
        public int read() { 
                return 0; 
        } 
} 

Steps to Reproduce: 
1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
2. Compile test2.java using BEA 1.4 javac 
> javac -d . test2.java 
3. Run java using compatible VM (J9) 
> java -showversion test2

Output: 
C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
java version "1.4.2_04" 
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 

BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads,
GC strategy: parallel) 

java.io.IOException: line too long
        at java.util.jar.Attributes.read(Ljava.util.jar.Manifest$FastInputStream;[B)V(Attributes.java:356)
        at java.util.jar.Manifest.read(Ljava.io.InputStream;)V(Manifest.java:167)
        at test2.main([Ljava.lang.String;)V(test2.java:8)
PASSED

C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
java.lang.OutOfMemoryError
        at java.util.jar.InitManifest.readLines(InitManifest.java:224)
        at java.util.jar.InitManifest.<init>(InitManifest.java:61)
        at java.util.jar.Manifest.read(Manifest.java:273)
        at test2.main(test2.java:10)

Suggested junit test case:
------------------------ ManifestTest.java -------------------------------------------------

import junit.framework.*; 
import java.io.*;
import java.util.jar.Manifest; 
public class ManifestTest extends TestCase { 
    public static void main(String[] args) { 
        junit.textui.TestRunner.run(ManifestTest.class); 
    } 
    public void test_read () { 
        InputStream is = new InputStreamImpl(); 
        try { 
           new Manifest().read(is); 
        } catch (IOException e) { 
          //expected 
        }     
    } 
}

class InputStreamImpl extends InputStream 
        
    public InputStreamImpl() { 
        super(); 
    } 
    public int read() { 
        return 0; 
    } 
}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message