public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [java/PATCH] PR 30454 Fix bootstrap on a couple of targets, empty  "zip" file in class path can cause leakage of file streams
@ 2007-01-23 17:23 Andrew Pinski
  2007-01-23 17:50 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2007-01-23 17:23 UTC (permalink / raw)
  To: gcc-patches, java-patches

[-- Attachment #1: Type: text/plain, Size: 646 bytes --]

Hi,
  The problem here is that empty "zip" files in the classpath would
cause leakage of file streams which meant after a while, we hit the
limit of opened files.  So when we try to open a class file, we would
fail.

This patch closes the file streams which are not referenced anywhere
after the call to opendir_in_zip because of a check failed.

OK? Bootstrapped on powerpc-darwin with an open file limit of 256.  The
testsuite is running right now and will be done later tonight but
getting the bootstrap up and working is important.

Thanks,
Andrew Pinski

	* jcf-io.c (opendir_in_zip): Close the file if there is an error
	in the zip file.



[-- Attachment #2: fixjava.diff.txt --]
[-- Type: text/x-patch, Size: 577 bytes --]

Index: java/jcf-io.c
===================================================================
--- java/jcf-io.c	(revision 121081)
+++ java/jcf-io.c	(working copy)
@@ -134,10 +134,16 @@ opendir_in_zip (const char *zipfile, int
     {
       jcf_dependency_add_file (zipfile, is_system);
       if (read (fd, magic, 4) != 4 || GET_u4 (magic) != (JCF_u4)ZIPMAGIC)
-	return NULL;
+	{
+	  close (fd);
+	  return NULL;
+	}
       lseek (fd, 0L, SEEK_SET);
       if (read_zip_archive (zipf) != 0)
-	return NULL;
+	{
+	  close (fd);
+	  return NULL;
+	}
     }
 
   SeenZipFiles = zipf;  

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [java/PATCH] PR 30454 Fix bootstrap on a couple of targets, empty  "zip" file in class path can cause leakage of file streams
  2007-01-23 17:23 [java/PATCH] PR 30454 Fix bootstrap on a couple of targets, empty "zip" file in class path can cause leakage of file streams Andrew Pinski
@ 2007-01-23 17:50 ` Tom Tromey
  2007-01-24  5:46   ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2007-01-23 17:50 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches, java-patches

>>>>> "Andrew" == Andrew Pinski <pinskia@gmail.com> writes:

Andrew> The problem here is that empty "zip" files in the classpath
Andrew> would cause leakage of file streams which meant after a while,
Andrew> we hit the limit of opened files.

Nice catch, thanks.

Andrew> OK?

I think we should free 'zipf' in the 'return NULL' cases.
Ok with that change.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [java/PATCH] PR 30454 Fix bootstrap on a couple of targets,  empty  "zip" file in class path can cause leakage of file streams
  2007-01-23 17:50 ` Tom Tromey
@ 2007-01-24  5:46   ` Andrew Pinski
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Pinski @ 2007-01-24  5:46 UTC (permalink / raw)
  To: tromey; +Cc: gcc-patches, java-patches

[-- Attachment #1: Type: text/plain, Size: 644 bytes --]

On Tue, 2007-01-23 at 08:40 -0700, Tom Tromey wrote:
> >>>>> "Andrew" == Andrew Pinski <pinskia@gmail.com> writes:
> 
> Andrew> The problem here is that empty "zip" files in the classpath
> Andrew> would cause leakage of file streams which meant after a while,
> Andrew> we hit the limit of opened files.
> 
> Nice catch, thanks.
> 
> Andrew> OK?
> 
> I think we should free 'zipf' in the 'return NULL' cases.
> Ok with that change.

And this is what I applied.

Thanks,
Andrew Pinski

2007-01-23  Andrew Pinski  <pinskia@gmail.com>

	PR java/30454
	* jcf-io.c (opendir_in_zip): Close the file
	and free zipf before returning after an error.



[-- Attachment #2: fixjava.diff.txt --]
[-- Type: text/x-patch, Size: 1041 bytes --]

Index: java/ChangeLog
===================================================================
--- java/ChangeLog	(revision 121100)
+++ java/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2007-01-23  Andrew Pinski  <pinskia@gmail.com>
+
+	PR java/30454
+	* jcf-io.c (opendir_in_zip): Close the file
+	and free zipf before returning after an error.
+
 2007-01-16  Tom Tromey  <tromey@redhat.com>
 
 	* java-tree.def: Added copyright header.
Index: java/jcf-io.c
===================================================================
--- java/jcf-io.c	(revision 121081)
+++ java/jcf-io.c	(working copy)
@@ -134,10 +134,18 @@ opendir_in_zip (const char *zipfile, int
     {
       jcf_dependency_add_file (zipfile, is_system);
       if (read (fd, magic, 4) != 4 || GET_u4 (magic) != (JCF_u4)ZIPMAGIC)
-	return NULL;
+	{
+	  free (zipf);
+	  close (fd);
+	  return NULL;
+	}
       lseek (fd, 0L, SEEK_SET);
       if (read_zip_archive (zipf) != 0)
-	return NULL;
+	{
+	  free (zipf);
+	  close (fd);
+	  return NULL;
+	}
     }
 
   SeenZipFiles = zipf;  

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-24  5:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-23 17:23 [java/PATCH] PR 30454 Fix bootstrap on a couple of targets, empty "zip" file in class path can cause leakage of file streams Andrew Pinski
2007-01-23 17:50 ` Tom Tromey
2007-01-24  5:46   ` Andrew Pinski

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).