Bug 20389 - [4.0/4.1 Regression] BufferedInputStream gets ArrayIndexOutOfBoundsExeception
Summary: [4.0/4.1 Regression] BufferedInputStream gets ArrayIndexOutOfBoundsExeception
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: David Daney
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2005-03-08 21:09 UTC by David Daney
Modified: 2005-03-09 22:44 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux
Target: i686-pc-linux
Build: i686-pc-linux
Known to work: 3.4.3 3.3.3
Known to fail: 4.0.0 4.1.0
Last reconfirmed: 2005-03-08 21:32:28


Attachments
Testcase (443 bytes, text/plain)
2005-03-08 21:16 UTC, David Daney
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Daney 2005-03-08 21:09:15 UTC
 
Comment 1 David Daney 2005-03-08 21:13:18 UTC
I will attach a testcase.

I also have a tentative patch and Mauve test that I will submit shortly.
Comment 2 David Daney 2005-03-08 21:16:52 UTC
Created attachment 8367 [details]
Testcase

As shown in the testcase, a series of marks and reads can cause either
ArrayIndexOutOfBoundsException or erroneous EOF.
Comment 3 Andrew Pinski 2005-03-08 21:23:11 UTC
Confirmed.
Comment 4 David Daney 2005-03-09 00:16:38 UTC
Patch posted here:

http://gcc.gnu.org/ml/java-patches/2005-q1/msg00669.html
Comment 5 GCC Commits 2005-03-09 21:20:55 UTC
Subject: Bug 20389

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	daney@gcc.gnu.org	2005-03-09 21:20:44

Modified files:
	libjava        : ChangeLog 
	libjava/java/io: BufferedInputStream.java InputStreamReader.java 

Log message:
	2005-03-09  David Daney  <ddaney@avtrex.com>
	
	PR libgcj/20389
	Merge BufferedInputStream from GNU Classpath.
	* java/io/BufferedInputStream.java (marktarget): Field removed.
	(CHUNKSIZE): Field removed.
	(bufferSize): New field.
	(BufferedInputStream): Initialize fields.
	(close): Invalidate mark and buffer indexes.
	(mark):  Rewritten.
	(read()): Move mark handling code to refill.
	(read(byte[], int, int)): Ditto.
	(skip): Ditto and simplify EOF testing.
	(refill): Rewritten.
	* java/io/InputStreamReader.java (refill): Removed mark and reset
	of internal BufferedInputStream.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.9&r2=1.3391.2.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/io/BufferedInputStream.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.11&r2=1.11.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/io/InputStreamReader.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.18&r2=1.18.2.1

Comment 6 GCC Commits 2005-03-09 22:11:40 UTC
Subject: Bug 20389

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	daney@gcc.gnu.org	2005-03-09 22:11:34

Modified files:
	libjava        : ChangeLog 
	libjava/java/io: BufferedInputStream.java InputStreamReader.java 

Log message:
	2005-03-09  David Daney  <ddaney@avtrex.com>
	
	PR libgcj/20389
	Merge BufferedInputStream from GNU Classpath.
	* java/io/BufferedInputStream.java (marktarget): Field removed.
	(CHUNKSIZE): Field removed.
	(bufferSize): New field.
	(BufferedInputStream): Initialize fields.
	(close): Invalidate mark and buffer indexes.
	(mark):  Rewritten.
	(read()): Move mark handling code to refill.
	(read(byte[], int, int)): Ditto.
	(skip): Ditto and simplify EOF testing.
	(refill): Rewritten.
	* java/io/InputStreamReader.java (refill): Removed mark and reset
	of internal BufferedInputStream.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3406&r2=1.3407
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/io/BufferedInputStream.java.diff?cvsroot=gcc&r1=1.11&r2=1.12
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/io/InputStreamReader.java.diff?cvsroot=gcc&r1=1.18&r2=1.19

Comment 7 Andrew Pinski 2005-03-09 22:44:25 UTC
Fixed.