|Summary:||Out of memory when classpath contains jar file with zip-style comment|
|Product:||gcc||Reporter:||Wil Mahan <wmahan>|
|Component:||java||Assignee:||Not yet assigned to anyone <unassigned>|
|Severity:||normal||CC:||bflat1, gcc-bugs, java-prs, tromey|
|Build:||Known to work:|
|Known to fail:||Last reconfirmed:||2005-08-29 04:56:23|
|Attachments:||Possible fix for gcc/java/zextract.c against latest CVS|
Description Wil Mahan 2005-08-29 04:50:25 UTC
When trying to compile a file with Debian's gcj 4.0.1-2, I got an error like this: HelloWorld.java:0: error: malformed .zip archive in CLASSPATH: /usr/lib/j2re1.5-sun/lib/ext/localedata.jar/ jc1: out of memory allocating 1342179073 bytes after a total of 389120 bytes It turns out the .jar file the error mentions has a zipfile comment. (JAR is based on the zip format, which allows an variable-length comment at the end of the file.) The compilation was successful when I removed the jar file from the classpath. Here's a simple test case to summarize: with gcj 4.0.1, the Info-ZIP utility, and any class, say HelloWorld.java: $ jar -cf test.jar; gcj -classpath test.jar HelloWorld.java # works fine $ jar -cf test.jar; echo "some comment" | zip -z test.jar; gcj -classpath test.jar HelloWorld.java enter new zip file comment (end with .): jc1: out of memory allocating 1663067502 bytes after a total of 135168 bytes This problem is similar to bug 13020 for FastJar. I came up with a similar solution: modifying zextract.c to check for a zipfile comment, and if necessary scan backwards for the end-central-header signature. Unfortunately I haven't had a chance to test the change compiled into gcc, although it appears to work in a small test program.
Comment 1 Wil Mahan 2005-08-29 04:53:44 UTC
Created attachment 9611 [details] Possible fix for gcc/java/zextract.c against latest CVS
Comment 2 Andrew Pinski 2005-08-29 04:56:23 UTC
Confirmed, I thought there was already a bug about this (not the fast jar one you pointed out) but looks like there is not. Could you sent your patch to java-patches@ and gcc-patches@ with a changelog and a comment and what this patch does?
Comment 3 Wil Mahan 2005-08-29 06:02:06 UTC
Done. I expected a bug to already have been reported about this, but I couldn't find one. Thanks for the fast response!
Comment 4 Tom Tromey 2005-10-03 14:26:10 UTC
*** Bug 24162 has been marked as a duplicate of this bug. ***
Comment 5 CVS Commits 2005-10-24 17:22:48 UTC
Subject: Bug 23617 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: firstname.lastname@example.org 2005-10-24 17:22:41 Modified files: gcc/java : ChangeLog zextract.c Log message: 2005-10-24 Wil Mahan <email@example.com> PR java/23617 * zextract.c (read_zip_archive): Fix out of memory error when reading jar files with zip-style comments. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1556.2.38&r2=1.1556.2.39 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/zextract.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.19&r2=22.214.171.124
Comment 6 Tom Tromey 2005-11-08 19:10:44 UTC
Subject: Bug 23617 Author: tromey Date: Tue Nov 8 19:10:39 2005 New Revision: 106648 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106648 Log: 2005-11-08 Wil Mahan <firstname.lastname@example.org> PR java/23617 * zextract.c (read_zip_archive): Fix out of memory error when reading jar files with zip-style comments. Modified: trunk/gcc/java/ChangeLog trunk/gcc/java/zextract.c
Comment 7 Tom Tromey 2005-11-08 19:11:52 UTC
Fix is on 4.0 branch and trunk.