public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16905] New: ICE (segfault) while compiling with -funit-at-a-time
@ 2004-08-06 21:02 rjpeters at klab dot caltech dot edu
  2004-08-06 21:06 ` [Bug c++/16905] " rjpeters at klab dot caltech dot edu
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rjpeters at klab dot caltech dot edu @ 2004-08-06 21:02 UTC (permalink / raw)
  To: gcc-bugs

Got an ICE while compiling the following:

/****** begin code ******/
#include <new> /* for placement new */

/* don't need definitions of these to trigger the segfault*/
extern int dummy_int;
extern bool dummy_bool;

/* don't need definitions of this functions to trigger the segfault */
int* dummy_get_int_ptr();

struct Data
{
  Data()
  {
    if (dummy_bool)
      {
        int* buf = dummy_get_int_ptr();

        try
          {
            int* cur = buf + 1;
            while (cur > buf)
              new (--cur) int;
          }
        catch (...)
          {
            while (true) /* nothing */ ;
          }
      }

    dummy_int = 0;
  }
};

struct Guard
{
  ~Guard()
  {
    while (true) /* nothing */ ;
  }
};

/* this variable has to be declared at file-scope, not at function-scope
   inside crash(), in order to trigger the segfault */
Data* px = 0;

/* we DO need a defintion of this function (albeit empty) to trigger the
   segfault -- also need the throw-spec -- also needs to be declared
   'inline' */
inline void do_nothing_nothrow() throw()
{}

void crash()
{
  px = new Data;
  Guard g;
  do_nothing_nothrow();
}
/******** end code ********/

Here's the result of running g++ 3.4.1:

/usr/local/gcc-3.4.1/bin/g++-3.4.1 -v -c fail.C -O1 -funit-at-a-time
Reading specs from
/local/usr-local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: /home/rjpeters/build/gcc-3.4.1/configure
--prefix=/usr/local/gcc-3.4.1 --program-suffix=-3.4.1 --enable-shared
--enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.4.1
 /local/usr-local/gcc-3.4.1/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.1/cc1plus
-quiet -v -iprefix
/local/usr-local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/ -D_GNU_SOURCE
fail.C -quiet -dumpbase fail.C -mtune=pentiumpro -auxbase fail -O1 -version
-funit-at-a-time -o /tmp/ccbsTsAR.s
ignoring nonexistent directory
"/local/usr-local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory
"/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1"
ignoring duplicate directory
"/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/i686-pc-linux-gnu"
ignoring duplicate directory
"/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward"
ignoring duplicate directory
"/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/include"
ignoring nonexistent directory
"/usr/local/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /local/usr-local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1
 /local/usr-local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/i686-pc-linux-gnu
 /local/usr-local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward
 /local/usr-local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/include
 /usr/local/include
 /usr/local/gcc-3.4.1/include
 /usr/include
End of search list.
GNU C++ version 3.4.1 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.1.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64322
fail.C: In function `void crash()':
fail.C:57: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


I spent some time whittling down the test case to what I've presented here...
seems that each of the remaining lines is required to manifest the segfault,
including the various pieces of do-nothing code (e.g. "while (true)
/*nothing*/;" and "dummy_int = 0").

Compiles without problem using 3.3.x, presumably because there's no
-funit-at-a-time option there:

/usr/bin/g++ -v -c fail.C -O1
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
 /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/cc1plus -quiet -v -D__GNUC__=3
-D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 -D_GNU_SOURCE fail.C -D__GNUG__=3
-quiet -dumpbase fail.C -auxbase fail -O1 -version -o /tmp/ccc6nw5C.s
GNU C++ version 3.3.2 20031022 (Red Hat Linux 3.3.2-1) (i386-redhat-linux)
        compiled by GNU C version 3.3.2 20031022 (Red Hat Linux 3.3.2-1).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64322
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.3.2
 /usr/include/c++/3.3.2/i386-redhat-linux
 /usr/include/c++/3.3.2/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/include
 /usr/include
End of search list.
 as -V -Qy -o fail.o /tmp/ccc6nw5C.s
GNU assembler version 2.14.90.0.6 (i386-redhat-linux) using BFD version
2.14.90.0.6 20030820


Seems to compile without problem using an old snapshot of 3.5:

/usr/bin/g++-ssa -I/usr/include/c++/3.5-tree-ssa -v -c fail.C -O1 -funit-at-a-time
Reading specs from /lib/ssa/gcc/i686-redhat-linux/3.5-tree-ssa/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --libdir=/lib/ssa --libexecdir=/lib/ssa
--host=i686-redhat-linux --enable-shared --enable-threads=posix
--disable-checking --enable-languages=c,c++,java,objc,f95 --with-system-zlib
--enable-__cxa_atexit --disable-multilib
Thread model: posix
gcc version 3.5-tree-ssa 20040122 (Fedora Core Rawhide 3.5ssa-snapshot)
 /lib/ssa/gcc/i686-redhat-linux/3.5-tree-ssa/cc1plus -quiet -v
-I/usr/include/c++/3.5-tree-ssa -D_GNU_SOURCE fail.C -quiet -dumpbase fail.C
-mtune=pentiumpro -auxbase fail -O1 -version -funit-at-a-time -o /tmp/cc2WuBtS.s
ignoring nonexistent directory
"/lib/ssa/gcc/i686-redhat-linux/3.5-tree-ssa/../../../../include/c++/3.5-tree-ssa"
ignoring nonexistent directory
"/lib/ssa/gcc/i686-redhat-linux/3.5-tree-ssa/../../../../include/c++/3.5-tree-ssa/i686-redhat-linux"
ignoring nonexistent directory
"/lib/ssa/gcc/i686-redhat-linux/3.5-tree-ssa/../../../../include/c++/3.5-tree-ssa/backward"
ignoring nonexistent directory
"/lib/ssa/gcc/i686-redhat-linux/3.5-tree-ssa/../../../../i686-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.5-tree-ssa
 /usr/local/include
 /lib/ssa/gcc/i686-redhat-linux/3.5-tree-ssa/include
 /usr/include
End of search list.
GNU C++ version 3.5-tree-ssa 20040122 (Fedora Core Rawhide 3.5ssa-snapshot)
(i686-redhat-linux)
        compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-20).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64322
 as -V -Qy -o fail.o /tmp/cc2WuBtS.s
GNU assembler version 2.14.90.0.6 (i386-redhat-linux) using BFD version
2.14.90.0.6 20030820


Thanks,
Rob Peters

-- 
           Summary: ICE (segfault) while compiling with -funit-at-a-time
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rjpeters at klab dot caltech dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16905


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

end of thread, other threads:[~2004-08-24 11:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-06 21:02 [Bug c++/16905] New: ICE (segfault) while compiling with -funit-at-a-time rjpeters at klab dot caltech dot edu
2004-08-06 21:06 ` [Bug c++/16905] " rjpeters at klab dot caltech dot edu
2004-08-06 21:06 ` rjpeters at klab dot caltech dot edu
2004-08-06 22:38 ` rjpeters at klab dot caltech dot edu
2004-08-06 23:23 ` [Bug c++/16905] [3.4 regression] ICE (segfault) with exceptions reichelt at gcc dot gnu dot org
2004-08-06 23:42 ` rjpeters at klab dot caltech dot edu
2004-08-09  1:37 ` pinskia at gcc dot gnu dot org
2004-08-24 11:24 ` reichelt at gcc dot gnu dot org

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