Bug 26881 - [4.1 Regression] internal compiler error in dwarf2out_finish
Summary: [4.1 Regression] internal compiler error in dwarf2out_finish
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.2
Assignee: Jan Hubicka
URL:
Keywords: ice-on-valid-code, monitored
: 27036 27058 28379 28782 29650 30671 30782 31065 (view as bug list)
Depends on:
Blocks: 27036
  Show dependency treegraph
 
Reported: 2006-03-27 01:50 UTC by David Baron
Modified: 2007-03-07 10:09 UTC (History)
23 users (show)

See Also:
Host:
Target: dwarf2
Build:
Known to work: 4.0.3 4.2.0
Known to fail: 4.1.0
Last reconfirmed: 2006-06-30 06:06:18


Attachments
preprocessed source (jscpucfg.i) (7.43 KB, text/plain; charset=us-ascii)
2006-03-27 01:52 UTC, David Baron
Details
Patch in testing (3.24 KB, patch)
2006-08-07 08:01 UTC, Jan Hubicka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Baron 2006-03-27 01:50:32 UTC
I get an internal compiler error when compiling Mozilla's standalone spidermonkey JavaScript engine on x86, either with Fedora Core 5's gcc 4.1.0 or a gcc 4.1.0 built from the released source.  I did *not* see this error taking similar steps on x86_64.

jscpucfg.c:374: internal compiler error: in dwarf2out_finish, at dwarf2out.c:14116

I'll attach preprocessed source; I haven't had a chance to minimize the testcase.

I'm using:
$ /usr/local/gcc-4.1.0/bin/gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1.0/configure --prefix=/usr/local/gcc-4.1.0 --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++
Thread model: posix
gcc version 4.1.0
Comment 1 David Baron 2006-03-27 01:52:16 UTC
Created attachment 11132 [details]
preprocessed source (jscpucfg.i)

To see the bug, save this attachment as jscpucfg.i, and:

# gcc -c -o jscpucfg.o -g jscpucfg.i
Comment 2 Andrew Pinski 2006-03-27 01:56:58 UTC
Reducing.
Comment 3 Andrew Pinski 2006-03-27 02:08:49 UTC
Reduced testcase that fails even on x86_64:
int main(int argc, char **argv)
{
 if (0)
 {
   static union{} u;
   typedef char tt;
   static tt c[8];
   return c[0] == 0x01 && c[1] == 0x02;
 }
}
Comment 4 Richard Biener 2006-03-27 08:17:37 UTC
(gdb) up
#1  0x082e8034 in dwarf2out_finish (filename=0xbfb6d1ca "t.c")
    at /space/rguenther/src/svn/summit/gcc/dwarf2out.c:14104
14104                 gcc_assert (context && TREE_CODE (context) == FUNCTION_DECL);
(gdb) print context
$1 = (tree) 0xb7d91138
(gdb) call debug_generic_expr(context)
BLOCK
  SUPERCONTEXT: BLOCK 0xb7d9116c
  VARS: unionunion 
{
} uD.1525 ttD.1526 cD.1527 

eh?  what's that?  cfun is also NULL.

(gdb) call debug_generic_expr(node->created_for)
union 
{
}
Comment 5 Andrew Pinski 2006-04-06 16:21:36 UTC
*** Bug 27058 has been marked as a duplicate of this bug. ***
Comment 6 Couriousous 2006-04-16 13:07:15 UTC
Here is an another testcase:

void bar (void)
{
 if (0) {
      static enum {a} foo;
      switch (0)
        {
        default:
          return;
        }
    }
}


Fail compiling with -O0 -g on x86_64 with gcc 4.1.1
Comment 7 Jakub Jelinek 2006-04-19 13:00:51 UTC
Honza, this is caused by your patch:
http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00661.html
In -fno-unit-at-a-time mode, we used to pass the local var to dwarf2out only
when the containing function has been registered with dwarf2out, but now we
call dwarf2out_global_decl on local variables first and only after that dwarf2out_decl on the containing function.
Comment 8 Jan Hubicka 2006-04-30 14:30:56 UTC
Jakub,
adding a worklist and passing all variables to dwarf2out as last it quite easy to do.  However could you enlighten me a bit why the particular order is needed?
Honza
Comment 9 Jakub Jelinek 2006-05-05 12:26:37 UTC
For static variables in function contexts dwarf2out in several places wants
to look up the parent context DIE.  Now when the variables are registered
with dwarf2out before the containing function, the parent context DIE doesn't
exist yet.
Comment 10 Flash Sheridan 2006-05-10 20:08:06 UTC
PalmSource bug #126750.
Comment 11 Mark Mitchell 2006-05-25 02:34:17 UTC
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
Comment 12 Martin Reinecke 2006-05-29 08:53:57 UTC
This bug prevents the current release of the Globus toolkit
(www.globus.org) from compiling.
Comment 13 Falk Hueffner 2006-07-14 12:26:15 UTC
*** Bug 28379 has been marked as a duplicate of this bug. ***
Comment 14 Jan Hubicka 2006-08-07 08:01:55 UTC
Created attachment 12032 [details]
Patch in testing
Comment 15 stephan beal 2006-08-07 09:47:47 UTC
(In reply to comment #12)
> This bug prevents the current release of the Globus toolkit
> (www.globus.org) from compiling.

A semi-workaround for getting SpiderMonkey to build is to export the BUILD_OPT=1 environment variable. This tells the SpiderMonkey makefile to turn off debugging, which causes the error to disappear. The down-side is that the library is then built to another directory, so you may have to change your Makefiles to accommodate finding the .so file in another place. For example, on my machine it is output to js/Linux_All_OPT.OBJ/.


Comment 16 Andrew Pinski 2006-08-18 04:20:01 UTC
(In reply to comment #14)
Any news on the patch?
Comment 17 Richard Biener 2006-08-20 09:14:05 UTC
*** Bug 28782 has been marked as a duplicate of this bug. ***
Comment 18 Jan Hubicka 2006-08-20 12:47:31 UTC
Subject: Re:  [4.1/4.2 Regression] internal compiler error in dwarf2out_finish

> (In reply to comment #14)
> Any news on the patch?

Sadly we are having just tip of the iceberg here.  The patch to deffer
output of debug symbols later sort of work, but I noticed there are
other PRs related to problem where optimized out static variable is
still referred to by debug info, so I attempted to move debug output
code to cgraph domain and failed to do so.  The problem is that we are
quite inconsistent in way we do handle the optimized out variables.  In
some cases we do emit debug output for them, in other we don't and
in another we ICE depending on case and forntend.

I guess I will back out and implement the deferring itself without
touching the whole issue for start.  THen we probably ought to teach
debug info output machinery to query cgraph about whether the particular
variable was output or not and output the location or optimized out info
and move the debug output to cgraph at last (for both local and external
stuff, so we will need new datastructure in cgraph holding all
declarations in program somehow, as this is for now maintained only by
frontends)

Honza
Comment 19 Jan Hubicka 2006-08-24 13:30:53 UTC
Subject: Bug 26881

Author: hubicka
Date: Thu Aug 24 13:30:45 2006
New Revision: 116374

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116374
Log:
	PR debug/26881
	* cgraph.c: Fix comments.
	(cgraph_varpool_mark_needed_node): Mark only variables not already
	output to file.
	* cgraphunit.c: Update comments; include gt-cgraphunit.h
	(cgraph_varpool_assembled_nodes_queue): New static variable.
	(cgraph_varpool_assemble_decl): Record output decls for debug out code.
	(cgraph_varpool_output_debug_info): New function.
	(cgraph_finalize_compilation_unit, cgraph_optimize): Call it.
	* Makefile.in: Add gt-cgraphunit.h
	* gcc.dg/debug/pr26881.c: New file.

Added:
    trunk/gcc/testsuite/gcc.dg/debug/pr26881.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/cgraph.c
    trunk/gcc/cgraphunit.c
    trunk/gcc/testsuite/ChangeLog

Comment 20 Martin Michlmayr 2006-10-14 16:48:46 UTC
Jan, do you intend to apply this to 4.1?
Comment 21 Richard Biener 2006-10-17 11:30:42 UTC
Subject: Bug 26881

Author: rguenth
Date: Tue Oct 17 11:30:28 2006
New Revision: 117823

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117823
Log:
2006-10-17  Richard Guenther  <rguenther@suse.de>

        Backport from mainline:
        2006-05-11  Jan Hubicka  <jh@suse.cz>

	PR debug/26881
	* Makefile.in (gt-cgraphunit.h): Add.
	* cgraphunit.c: Include gt-cgraphunit.h.
	(local_static_output): New static vector.
	(cgraph_varpool_assemble_decl): Defer outputting debug info
	for local statics to...
	(cgraph_varpool_debug_local_statics): ... here.
	(cgraph_optimize): Use it.

        2006-05-12  Jakub Jelinek  <jakub@redhat.com>

	PR debug/26881
	* gcc.dg/debug/pr26881.c: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/debug/pr26881.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/Makefile.in
    branches/gcc-4_1-branch/gcc/cgraphunit.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 22 Richard Biener 2006-10-17 11:31:22 UTC
Fixed.
Comment 23 Richard Biener 2006-10-17 11:33:15 UTC
*** Bug 27036 has been marked as a duplicate of this bug. ***
Comment 24 Stefan Urbat 2006-10-30 07:32:09 UTC
I get this very same issue also on sparc-solaris 2.10 with the mentioned source and gcc v 4.1.1. So I hope 4.1.2 will fix this there too, but I get it there only with option -ggdb, in case this helps anyway. Alternatively I could try that patch on 4.1.1 myself... (I compiled that one myself)
Comment 25 Andrew Pinski 2006-10-30 17:02:54 UTC
*** Bug 29650 has been marked as a duplicate of this bug. ***
Comment 26 Stefan Urbat 2006-10-30 18:23:10 UTC
It seemed too difficult and risky to me to resolve the numerous rejects of the attached patch against the 4.1.1 release, so I checked out today via svn the 4.1 branch in current state (30.10.2006). After changing a mask in the gcc directory Makefile created by configure (sed needed there ' instead of ", I didn't check, if gsed would have sufficed, but this was with /usr/xpg4/bin/sed, so it is SUS V3 conformant) I succeeded in compiling that one and it resolved this issue for me indeed when using the option -ggdb --- and works also if not using this option.
Comment 27 Richard Biener 2007-02-02 11:18:19 UTC
*** Bug 30671 has been marked as a duplicate of this bug. ***
Comment 28 Andrew Pinski 2007-02-13 00:37:38 UTC
*** Bug 30782 has been marked as a duplicate of this bug. ***
Comment 29 Richard Biener 2007-03-07 10:09:03 UTC
*** Bug 31065 has been marked as a duplicate of this bug. ***