PCH merge: bootstrap failure, gengtype consumes all file descriptors

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Mon Jun 10 13:44:00 GMT 2002


I've been getting bootstrap failures in stage1 on solaris2.7 when
running gengtype, it says:

 > opening output file: Too many open files

On my box, the default fd limit is 64.  You can probably reproduce
this error by artificially setting your soft limit low enough.  You
also might need to start from a totally clean build dir, since when I
rerun gengtype, it sometimes succeeds.  Note it seems like we're just
barely at the limit since when I increase the limit to 65, it always
works.

I tracked how many open file descriptors we keep open in main after
each function call in gengtype.

fds open	after call
--------------------------
3		(prior to open_base_files)
12		open_base_files
29		write_gc_types

Then inside write_gc_roots there are loops over the `variables'
parameter which call get_output_file_with_visibility.  The FILE*s
returned by this function call are never closed so the fd count goes
up until it hits the system limit.  (And BTW the return value is not
checked so we don't know we got an error.)

Later on in close_output_files, where we do check the error status, we
notice all the fds are used up and give the error message above.

As I mentioned above, when I set the limit to 65, it works.  And later
on the open fd count drops back to 3 (std in,out,err) so apparently
this is not an fd leak, everything is tracked and closed.  Instead we
have a design problem in that the code expects to have all these
descriptors available to it.  I think that's a bad assumption.

		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Solutions



More information about the Gcc-bugs mailing list