public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch
@ 2004-03-05 9:27 gcj at stuellenberg dot de
2004-03-05 9:30 ` [Bug java/14446] " gcj at stuellenberg dot de
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: gcj at stuellenberg dot de @ 2004-03-05 9:27 UTC (permalink / raw)
To: gcc-bugs
Using the GZIPInputStream I found out, that "sometimes" but not always the
following exception gets thrown (I've attached a file that causes the error):
java.util.zip.ZipException: corrupted gzip file - crc mismatch
So, you might use GZIPOutputStream to compress and then while
decompressing the error gets thrown.
I'm going to attach a small jar, that you might use to test.
java -jar zipper.jar compress test-document test-compressed
java -jar zipper.jar uncompress test-compressed test-uncompressed
Java version works without any problems...
gcj --main=com.condor_edv.e3m.util.compress.fun -o zipper zipper.jar
zipper compress test-document test-compressed
zipper uncompress test-compressed test-uncompressed
throws the error...
The source for the zipper.jar is compiled through nice (nice.sf.net)
but it only contains the following:
class CompressTest {
public void deflate(InputStream in, OutputStream out)
{
byte[] ba = new byte[buffersize];
int b, count = 0;
GZIPOutputStream gout = new GZIPOutputStream(out);
try {
while (true) {
b = in.read();
if (b == -1) throw new EOFException();
ba[count++] = byte(b);
if (count == buffersize) {
count = 0;
gout.write(ba, 0, buffersize);
}
}
} catch (EOFException eof) {
}
gout.write(ba, 0, count);
gout.finish();
}
public void inflate(InputStream in, OutputStream out)
{
byte[] ba = new byte[buffersize];
int b, count = 0;
GZIPInputStream gin = new GZIPInputStream(in);
try {
while (true) {
b = gin.read();
if (b == -1) throw new EOFException();
ba[count++] = byte(b);
if (count == buffersize) {
count = 0;
out.write(ba, 0, buffersize);
}
}
} catch (EOFException eof) {
}
out.write(ba, 0, count);
out.flush();
}
}
void main(String[] args)
{
try {
if (args.length == 3) {
CompressTest c = new CompressTest();
// ok, let us convert some files
// (load|save) in out
FileInputStream in = new FileInputStream(args[1]);
FileOutputStream out = new FileOutputStream(args[2]);
if (args[0].equals("compress")) {
c.deflate(in, out);
} else if (args[0].equals("uncompress")) {
c.inflate(in, out);
} else System.out.println("Unknown Action: "+args[0]);
in.close();
out.close();
} else {
System.out.println("Unsupported Action!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
Hopefully someone can reproduce the bug...
Kind regards,
Christian
--
Summary: GZIPInputStream: corrupted gzip file - crc mismatch
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcj at stuellenberg dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i586-pc-linux-gnu
GCC host triplet: i586-pc-linux-gnu
GCC target triplet: i586-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
@ 2004-03-05 9:30 ` gcj at stuellenberg dot de
2004-03-05 9:31 ` gcj at stuellenberg dot de
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: gcj at stuellenberg dot de @ 2004-03-05 9:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gcj at stuellenberg dot de 2004-03-05 09:30 -------
Created an attachment (id=5865)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5865&action=view)
A small executable jar to show the bug
Use this executable jar to show, that under java working, but with gcj compiled
to native, no longer working.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
2004-03-05 9:30 ` [Bug java/14446] " gcj at stuellenberg dot de
@ 2004-03-05 9:31 ` gcj at stuellenberg dot de
2004-09-22 16:02 ` sorabain at hotmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: gcj at stuellenberg dot de @ 2004-03-05 9:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gcj at stuellenberg dot de 2004-03-05 09:31 -------
Created an attachment (id=5866)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5866&action=view)
A file that raises the exception
This file raises the exception at my installation.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
2004-03-05 9:30 ` [Bug java/14446] " gcj at stuellenberg dot de
2004-03-05 9:31 ` gcj at stuellenberg dot de
@ 2004-09-22 16:02 ` sorabain at hotmail dot com
2004-09-22 19:27 ` tromey at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sorabain at hotmail dot com @ 2004-09-22 16:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From sorabain at hotmail dot com 2004-09-22 16:02 -------
We had the same problem, and i found the cause:
java.util.zip.GZIPInputStream.java in libjava has a method called read4() that
reads in 4 bytes and returns them as an int (java integers are signed). this
is compared to CRC32.getValue(), which returns a long. The int is promoted to
a long for the comparison, but if the most significant (sign) bit is set this
will be a negative number, whereas the long with the same original low 32-bits
is positive. The comparison fails.
To fix it i just changed the return type of read4() to be a long in-line with
the type of CRC32.getValue()
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
` (2 preceding siblings ...)
2004-09-22 16:02 ` sorabain at hotmail dot com
@ 2004-09-22 19:27 ` tromey at gcc dot gnu dot org
2004-09-22 19:42 ` tromey at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tromey at gcc dot gnu dot org @ 2004-09-22 19:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tromey at gcc dot gnu dot org 2004-09-22 19:27 -------
I don't see an exception here, but I do see that
I don't get the right results if I compress and
then compress the test file.
I do see an exception with gcj 3.3.3.
Comparing output with the JDK it appears that
our GZIPOutputStream is ok.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
` (3 preceding siblings ...)
2004-09-22 19:27 ` tromey at gcc dot gnu dot org
@ 2004-09-22 19:42 ` tromey at gcc dot gnu dot org
2004-09-22 20:16 ` cvs-commit at gcc dot gnu dot org
2004-09-22 20:17 ` tromey at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: tromey at gcc dot gnu dot org @ 2004-09-22 19:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tromey at gcc dot gnu dot org 2004-09-22 19:42 -------
I'm testing a fix for this.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |tromey at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
` (4 preceding siblings ...)
2004-09-22 19:42 ` tromey at gcc dot gnu dot org
@ 2004-09-22 20:16 ` cvs-commit at gcc dot gnu dot org
2004-09-22 20:17 ` tromey at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-09-22 20:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-09-22 20:16 -------
Subject: Bug 14446
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: tromey@gcc.gnu.org 2004-09-22 20:16:17
Modified files:
libjava : ChangeLog
libjava/java/util/zip: GZIPInputStream.java
InflaterInputStream.java
Log message:
PR libgcj/14446:
* java/util/zip/GZIPInputStream.java (read): Avoid sign extension
when comparing CRCs.
* java/util/zip/InflaterInputStream.java (onebytebuffer): New
field.
(read()): New overload.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3063&r2=1.3064
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/util/zip/GZIPInputStream.java.diff?cvsroot=gcc&r1=1.9&r2=1.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/util/zip/InflaterInputStream.java.diff?cvsroot=gcc&r1=1.21&r2=1.22
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
` (5 preceding siblings ...)
2004-09-22 20:16 ` cvs-commit at gcc dot gnu dot org
@ 2004-09-22 20:17 ` tromey at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: tromey at gcc dot gnu dot org @ 2004-09-22 20:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tromey at gcc dot gnu dot org 2004-09-22 20:17 -------
I was able to reproduce the exception after all, after
fixing a problem with InflaterInputStream.
I've checked in a fix for both problems.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-09-22 20:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-05 9:27 [Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch gcj at stuellenberg dot de
2004-03-05 9:30 ` [Bug java/14446] " gcj at stuellenberg dot de
2004-03-05 9:31 ` gcj at stuellenberg dot de
2004-09-22 16:02 ` sorabain at hotmail dot com
2004-09-22 19:27 ` tromey at gcc dot gnu dot org
2004-09-22 19:42 ` tromey at gcc dot gnu dot org
2004-09-22 20:16 ` cvs-commit at gcc dot gnu dot org
2004-09-22 20:17 ` tromey at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).