Bug 11654 - incorrect stabs when using pre-compiled headers
Summary: incorrect stabs when using pre-compiled headers
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: pch (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2003-07-24 02:19 UTC by Andrew Tridgell
Modified: 2009-09-20 11:14 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: *-*-*
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-11-02 01:48:57


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Tridgell 2003-07-24 02:19:19 UTC
I get a "internal compiler error: Segmentation fault" when using pre-compiled
headers and -gstabs and the pre-compiled header is included indirectly via
another include. The bug does not occur without pre-compiled headers.

I am using the Debian unstable gcc-snapshot package, identified as:
    gcc version 3.4 20030706 (experimental)
I have asked the debian maintainer, and apparently this corresponds exactly with
the 20030706 gcc snapshot.

The simplest test case I have found is as follows:

test.c:
    #include "test.h"

    void test(void) {}

test.h:
   #include "includes.h"

includes.h:
   /* an empty header */

Makefile:
   CC=gcc-snapshot
   CFLAGS=-gstabs

   all: includes.h.gch test.o

   test.o: test.c
        $(CC) $(CFLAGS) -c test.c

   includes.h.gch: includes.h
        $(CC) $(CFLAGS) -c includes.h -o includes.h.gch

   clean:
        rm -f *~ *.o *.gch
Comment 1 Andrew Pinski 2003-07-24 02:33:01 UTC
I can confirm this on the mainline (20030723).

emit_pending_bincls () at /home/gates/pinskia/src/gnu/gcc/src/gcc/dbxout.c:592
592         f = f->next;
(gdb) bt
#0  emit_pending_bincls () at /home/gates/pinskia/src/gnu/gcc/src/gcc/dbxout.c:592
#1  0x080fc435 in dbxout_symbol (decl=0x400918dc, local=0) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/dbxout.c:580
#2  0x080fed21 in dbxout_begin_function (decl=0x400918dc) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/dbxout.c:3188
#3  0x08317abb in assemble_start_function (decl=0x400918dc, fnname=0x85389dd "test")
    at /home/gates/pinskia/src/gnu/gcc/src/gcc/varasm.c:1087
#4  0x082f87bd in rest_of_handle_final (decl=0x400918dc, insns=0x4004c3e0) at /home/gates/
pinskia/src/gnu/gcc/src/gcc/toplev.c:1987
#5  0x082fae7f in rest_of_compilation (decl=0x400918dc) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/toplev.c:3502
#6  0x0806d1a2 in c_expand_body_1 (fndecl=0x400918dc, nested_p=0) at /home/gates/pinskia/
src/gnu/gcc/src/gcc/c-decl.c:6425
#7  0x0806d709 in c_expand_body (fndecl=0x1) at /home/gates/pinskia/src/gnu/gcc/src/gcc/c-
decl.c:6507
#8  0x0806ccea in finish_function (nested=0, can_defer_p=1) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/c-decl.c:6295
#9  0x0804b4a9 in yyparse () at c-parse.y:385
#10 0x0805213b in c_parse_file () at c-parse.y:3022
#11 0x0809ad3b in c_common_parse_file (set_yydebug=1) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/c-opts.c:1211
#12 0x082f80ca in compile_file () at /home/gates/pinskia/src/gnu/gcc/src/gcc/toplev.c:1749
#13 0x082fca8e in do_compile () at /home/gates/pinskia/src/gnu/gcc/src/gcc/toplev.c:4526
#14 0x082fcba5 in toplev_main (argc=1, argv=0xbffec514) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/toplev.c:4567
#15 0x420174d9 in __libc_start_main () from /lib/i686/libc.so.6
#16 0x08049a11 in _start ()
(gdb) p f
$1 = (struct dbx_file *) 0x0
Comment 2 Andrew Pinski 2003-07-24 02:48:38 UTC
The function emit_pending_bincls was introduced by:
2003-07-01  Devang Patel

        * dbxout.c (DBXOUT_DECR_NESTING): Emit pending bincls, if required.
        (binclstatus): New.
        (struct dbx_file): New members - bincl_status, pending_bincl_name and
        prev.
        (pending_bincls): New.
        (dbxout_init): Initialize new dbx_file members.
        (dbxout_start_source_file): Same.
        (emit_bincl_stab): New function.
        (emit_pending_bincls): Same.
        (emit_pending_bincls_if_required): Same.
        (dbxout_end_source_file): Emit EINCL stab only if BINCL is  already
        processed.
        (dbxout_begin_block): Emit pending BINCL stabs.
        (dbxout_end_block): Same.
        (dbxout_function_decl): Same.
        (dbxout_continue): Same.
        (dbxout_type): Same.
        (dbxout_class_name_qualifiers): Same.
        (dbxout_symbol): Same.
        (dbxout_symbol_location): Same.
        (dbxout_parms): Same.
Comment 3 Geoff Keating 2003-07-24 06:46:42 UTC
Subject: Re:  New: gcc seg fault when using pre-compiled headers and -gstabs


This is known.  I have a testcase for this:

==> include-1.c <==
/* { dg-options "-I. -include $srcdir/gcc.dg/pch/include-1a.h" } */

int main(void)
{
  return 0;
}

==> include-1.hs <==
#include <stdio.h>


==> include-1a.h <==
#include "include-1.h"

It seems to be an incomplete merge from Apple's tree; that testcase
was originally written for Apple's compiler and it now passes there.
You can assign this bug to me, I will eventually get around to it.

Comment 4 Andrew Pinski 2003-07-24 11:12:02 UTC
Assigning to PCH expert
Comment 5 GCC Commits 2003-11-07 22:12:44 UTC
Subject: Bug 11654

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	geoffk@gcc.gnu.org	2003-11-07 22:12:40

Modified files:
	gcc            : ChangeLog dbxout.c 

Log message:
	PR 11654
	* dbxout.c (struct dbx_file): Do not save for PCH.
	(current_file): Likewise.
	(dbxout_init): Don't allocate struct dbx_file using GC.
	(dbxout_start_source_file): Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1698&r2=2.1699
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dbxout.c.diff?cvsroot=gcc&r1=1.164&r2=1.165

Comment 6 Geoff Keating 2003-12-16 18:11:07 UTC
Downgrading severity.  The problem is now incorrect stabs generation, which is not so severe.
Comment 7 Richard Biener 2009-09-20 11:14:27 UTC
Indirectly including a PCH is invalid.