I will attach a testcase. I also have a tentative patch and Mauve test that I will submit shortly.
Created attachment 8367 [details] Testcase As shown in the testcase, a series of marks and reads can cause either ArrayIndexOutOfBoundsException or erroneous EOF.
Confirmed.
Patch posted here: http://gcc.gnu.org/ml/java-patches/2005-q1/msg00669.html
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
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
Fixed.