This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Seg fault in fix-header; 20000320; Solaris
- To: Jeffrey A Law <law at cygnus dot com>
- Subject: Re: Seg fault in fix-header; 20000320; Solaris
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Wed, 29 Mar 2000 22:50:45 -0800
- Cc: Jim McKelvey <mckelvey at bean dot jpl dot nasa dot gov>, gcc-bugs at gcc dot gnu dot org
- References: <200003212055.MAA20908@mushroom.jpl.nasa.gov> <7294.954382387@upchuck>
On Wed, Mar 29, 2000 at 07:13:07PM -0700, Jeffrey A Law wrote:
>
> In message <200003212055.MAA20908@mushroom.jpl.nasa.gov>you write:
> >
> > cppinit.c does not check for NULL pointer, causing fix-header to crash.
...
> There's no explanation for why opts->in_fname was null to begin with --
> without that critical piece of information, it's much more difficult to
> tell if your patch is correct or if it's just papering over a problem
> elsewhere.
opts->in_fname is null at this point because
initialize_dependency_output is being called too early; that's the
real bug. The code that converts a null in_fname to an empty string
is in cpp_start_read, right after i_d_o; it should be right before.
I'll commit this patch after a bootstrap completes, and I will run
fix-header this time.
===================================================================
Index: cppinit.c
--- cppinit.c 2000/03/28 21:45:02 1.66
+++ cppinit.c 2000/03/30 06:49:04
@@ -896,10 +896,8 @@ cpp_start_read (pfile, fname)
fprintf (stderr, _("End of search list.\n"));
}
- initialize_dependency_output (pfile);
-
- /* Open the main input file. This must be done before -D processing
- so we have a buffer to stand on. */
+ /* Open the main input file. This must be done early, so we have a
+ buffer to stand on. */
if (opts->in_fname == NULL || *opts->in_fname == 0)
{
opts->in_fname = fname;
@@ -910,6 +908,8 @@ cpp_start_read (pfile, fname)
if (!cpp_read_file (pfile, fname))
return 0;
+ initialize_dependency_output (pfile);
+
/* -D and friends may produce output, which should be identified
as line 0. */