This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

debug/2377: Segfault in dbxout.c:1013



>Number:         2377
>Category:       debug
>Synopsis:       Segfault in dbxout.c:1013
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 24 12:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        3.0 20010321 (prerelease)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.2 #34 Sun Feb 25 20:03:34 CET 2001 i686 unknown
Architecture: i686
SuSE 7.1
Glibc 2.2
GNU ld version 2.11.90.0.1 (with BFD 2.11.90.0.1)
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
>Description:
The following legal source code tb4.C, extracted from the file
testsuite/chris-jeffery-1.cpp from blitz-20000122 and the header file
<complex>, generates an internal compiler error only if stabs (dbx)
debugging information (-g) is enabled. There is a segmentation fault  
in dbxout_type (type=0x0, full=0, show_arg_types=0) at dbxout.c:1013,
because the first argument "type" is a NULL pointer. 

If dwarf2 debugging (-ggdb) format is requested, the code compiles
without a warning and runs as expected. If optimization is added to
the command line, "CXXFLAGS=-O -g", there is no problem. 

G++-2.95.2 does crash with an internal error, regardless if debugging
information is requested or not.

>How-To-Repeat:
Source code tb4.C 
/***************************************************************************
 * blitz/array.h      Declaration of the Array<P_numtype, N_rank> class
 *
 * $Id: array.h,v 1.2 1998/03/14 00:04:47 tveldhui Exp $
 *
 * Copyright (C) 1997-1999 Todd Veldhuizen <tveldhui@oonumerics.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details. */

 namespace std
{

  // Forward declarations
  template<typename _Tp> class complex;
  template<> class complex<float>;
    
  // 26.2.2  Primary template class complex
  template<typename _Tp>
    class complex
    {
    public:
      complex(const _Tp& = _Tp(), const _Tp & = _Tp());

    private:
      _Tp _M_real, _M_imag;
    };

  template<typename _Tp>
    inline 
    complex<_Tp>::complex(const _Tp& __r, const _Tp& __i)
    : _M_real(__r), _M_imag(__i) { }

  template<> class complex<float>
  {
  public:
    complex(float = 0.0f, float = 0.0f);

  private:
    typedef __complex__ float _ComplexT;
    _ComplexT _M_value;

  };

  inline
  complex<float>::complex(float r, float i)
  {
    __real__ _M_value = r;
    __imag__ _M_value = i;
  }
 } // namespace std

namespace blitz
{

template<class T_array, class T_iterator = typename T_array::T_numtype*>
class ListInitializationSwitch {

public:
    typedef typename T_array::T_numtype T_numtype;

    ListInitializationSwitch(T_array& array, T_numtype value)
        : array_(array), value_(value)
    { }

private:
    ListInitializationSwitch();

protected:
    T_array& array_;
    T_numtype value_;
};

template<class P_type>
class MemoryBlockReference {
};

template<int N_rank>
class GeneralArrayStorage {
};

template<class P_numtype, int N_rank>
class Array : public MemoryBlockReference<P_numtype> 
{
public:
    typedef P_numtype                T_numtype;
    typedef Array<T_numtype, N_rank> T_array;

    explicit Array(int length0, 
        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
        : storage_(storage)
    {
        length0 = 0; //squelches warning
    }

    ListInitializationSwitch<T_array> operator=(T_numtype x)
    {
        return ListInitializationSwitch<T_array>(*this, x);
    }

protected:
    GeneralArrayStorage<N_rank> storage_;
};
}

using namespace blitz;
    
int main()
{
  Array<std::complex<float>,1> test2(5) ;
  test2 = std::complex<float>(3,3) ;
}

Compiling tb4.C
Compiling with stabs (dbx) debug format enabled
g++ -v -o tb4 tb4.C -W -Wall -g -save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
gcc version 3.0 20010321 (prerelease)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/cpp0 -lang-c++ -D_GNU_SOURCE -D__GNUG__=3 -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tb4.C tb4.ii
GNU CPP version 3.0 20010321 (prerelease) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -fpreprocessed tb4.ii -quiet -dumpbase tb4.C -g -W -Wall -version -o tb4.s
GNU CPP version 3.0 20010321 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010321 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.0 20010321 (prerelease).
tb4.C: In constructor `blitz::ListInitializationSwitch<T_array, 
   T_iterator>::ListInitializationSwitch(T_array&, typename T_array::T_numtype) 
   [with T_array = blitz::Array<std::complex<float>, 1>, T_iterator = 
   std::complex<float>*]':
tb4.C:71:   instantiated from `blitz::ListInitializationSwitch<T_array, T_iterator>::ListInitializationSwitch(T_array&, typename T_array::T_numtype) [with T_array = blitz::Array<std::complex<float>, 1>, T_iterator = std::complex<float>*]'
tb4.C:105:   instantiated from `blitz::ListInitializationSwitch<blitz::Array<P_numtype, N_rank>, P_numtype*> blitz::Array<P_numtype, N_rank>::operator=(P_numtype) [with P_numtype = std::complex<float>, int N_rank = 1]'
tb4.C:118:   instantiated from here
tb4.C:71: Internal error: Segmentation fault
Please submit a full bug report, with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

debugging the program:
gdb cc1plus
GNU gdb 20010114
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Breakpoint 1 at 0x8049568
Breakpoint 2 at 0x80df456: file diagnostic.c, line 1766.
Breakpoint 3 at 0x8049368
(gdb) set args -g tb4.C
(gdb) r
Starting program: /mnt/egcs/gcc/gcc/cc1plus -g tb4.C
Breakpoint 1 at 0x4004c285
Breakpoint 3 at 0x4004af27
 std::complex<_Tp>::complex(const _Tp&, const _Tp&) std::complex<float>::complex(float, float) std::complex<float>::complex(float, float) std::complex<float>::complex(float, float) blitz::ListInitializationSwitch<T_array, T_iterator>::ListInitializationSwitch(T_array&, typename T_array::T_numtype) blitz::Array<P_numtype, N_rank>::Array(int, blitz::GeneralArrayStorage<N_rank>) blitz::ListInitializationSwitch<blitz::Array<P_numtype, N_rank>, P_numtype*> blitz::Array<P_numtype, N_rank>::operator=(P_numtype) int main() int main() blitz::Array<P_numtype, N_rank>::Array(int, blitz::GeneralArrayStorage<N_rank>) [with P_numtype = std::complex<float>, int N_rank = 1] blitz::Array<P_numtype, N_rank>::Array(int, blitz::GeneralArrayStorage<N_rank>) [with P_numtype = std::complex<float>, int N_rank = 1] blitz::Array<P_numtype, N_rank>::Array(int, blitz::GeneralArrayStorage<N_rank>) [with P_numtype = std::complex<float>, int N_rank = 1] blitz::Array<P_numtype, N_rank>::Array(int, blitz::G!
 eneralArrayStorage<N_rank>) [with P_numtype = std::complex<float>, int N_rank = 1] blitz::ListInitializationSwitch<blitz::Array<P_numtype, N_rank>, P_numtype*> blitz::Array<P_numtype, N_rank>::operator=(P_numtype) [with P_numtype = std::complex<float>, int N_rank = 1] blitz::ListInitializationSwitch<blitz::Array<P_numtype, N_rank>, P_numtype*> blitz::Array<P_numtype, N_rank>::operator=(P_numtype) [with P_numtype = std::complex<float>, int N_rank = 1] blitz::ListInitializationSwitch<T_array, T_iterator>::ListInitializationSwitch(T_array&, typename T_array::T_numtype) [with T_array = blitz::Array<std::complex<float>, 1>, T_iterator = std::complex<float>*] blitz::ListInitializationSwitch<T_array, T_iterator>::ListInitializationSwitch(T_array&, typename T_array::T_numtype) [with T_array = blitz::Array<std::complex<float>, 1>, T_iterator = std::complex<float>*] blitz::ListInitializationSwitch<T_array, T_iterator>::ListInitializationSwitch(T_array&, typename T_array::T_numtype) [!
 with T_array = blitz::Array<std::complex<float>, 1>, T_iterator = std:
:complex<float>*] blitz::ListInitializationSwitch<T_array, T_iterator>::ListInitializationSwitch(T_array&, typename T_array::T_numtype) [with T_array = blitz::Array<std::complex<float>, 1>, T_iterator = std::complex<float>*]
Program received signal SIGSEGV, Segmentation fault.
dbxout_type (type=0x0, full=0, show_arg_types=0) at dbxout.c:1013
(gdb) bt
#0  dbxout_type (type=0x0, full=0, show_arg_types=0) at dbxout.c:1013
#1  0x0815458f in dbxout_symbol_location (decl=0x401929c0, type=0x0, 
    suffix=0x82efdcc "$real", home=0x40199c10) at dbxout.c:2207
#2  0x081545ef in dbxout_symbol_location (decl=0x401929c0, type=0x40178750, 
    suffix=0x0, home=0x40199c30) at dbxout.c:2179
#3  0x081553a7 in dbxout_reg_parms (parms=0x401928f0) at dbxout.c:2586
#4  0x08155527 in dbxout_block (block=0x4019a780, depth=0, args=0x401928f0)
    at dbxout.c:2682
#5  0x081557c8 in dbxout_function (decl=0x40192888) at dbxout.c:2798
#6  0x080dafc9 in rest_of_compilation (decl=0x40192888) at ./toplev.c:3764
#7  0x080bdb36 in genrtl_finish_function (fn=0x40192888) at cp/semantics.c:2640
#8  0x080bd752 in expand_body (fn=0x40192888) at cp/semantics.c:2427
#9  0x080c4de7 in maybe_clone_body (fn=0x4018eaf8) at cp/optimize.c:1081
#10 0x080bd664 in expand_body (fn=0x4018eaf8) at cp/semantics.c:2348
#11 0x08078061 in instantiate_decl (d=0x4018eaf8, defer_ok=0) at cp/pt.c:9966
#12 0x08078343 in instantiate_pending_templates () at cp/pt.c:10039
#13 0x080888cc in finish_file () at cp/decl2.c:3534
#14 0x08093b85 in yyparse_1 () at /usr/share/bison.simple:441
#15 0x080d92f8 in compile_file (name=0x83c4557 "tb4.C") at ./toplev.c:2389
#16 0x080dcd8e in main (argc=3, argv=0xbffff83c) at ./toplev.c:4958
#17 0x40039baf in __libc_start_main () from /lib/libc.so.6

Compiling with dwarf2 debug format enabled
g++ -o tb4 tb4.C -W -Wall -ggdb
echo $?
0
./tb4
echo $?
0

Compiling with stabs debug format and optimization enabled
g++ -o tb4 tb4.C -W -Wall -O -g
echo $?
0
./tb4
echo $?
0

Preprocessed source code tb4.ii
# 18 "tb4.C"
 namespace std
{


  template<typename _Tp> class complex;
  template<> class complex<float>;


  template<typename _Tp>
    class complex
    {
    public:
      complex(const _Tp& = _Tp(), const _Tp & = _Tp());

    private:
      _Tp _M_real, _M_imag;
    };

  template<typename _Tp>
    inline
    complex<_Tp>::complex(const _Tp& __r, const _Tp& __i)
    : _M_real(__r), _M_imag(__i) { }

  template<> class complex<float>
  {
  public:
    complex(float = 0.0f, float = 0.0f);

  private:
    typedef __complex__ float _ComplexT;
    _ComplexT _M_value;

  };

  inline
  complex<float>::complex(float r, float i)
  {
    __real__ _M_value = r;
    __imag__ _M_value = i;
  }
 }

namespace blitz
{

template<class T_array, class T_iterator = typename T_array::T_numtype*>
class ListInitializationSwitch {

public:
    typedef typename T_array::T_numtype T_numtype;

    ListInitializationSwitch(T_array& array, T_numtype value)
        : array_(array), value_(value)
    { }

private:
    ListInitializationSwitch();

protected:
    T_array& array_;
    T_numtype value_;
};

template<class P_type>
class MemoryBlockReference {
};

template<int N_rank>
class GeneralArrayStorage {
};

template<class P_numtype, int N_rank>
class Array : public MemoryBlockReference<P_numtype>
{
public:
    typedef P_numtype T_numtype;
    typedef Array<T_numtype, N_rank> T_array;

    explicit Array(int length0,
        GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>())
        : storage_(storage)
    {
        length0 = 0;
    }

    ListInitializationSwitch<T_array> operator=(T_numtype x)
    {
        return ListInitializationSwitch<T_array>(*this, x);
    }

protected:
    GeneralArrayStorage<N_rank> storage_;
};
}

using namespace blitz;

int main()
{
  Array<std::complex<float>,1> test2(5) ;
  test2 = std::complex<float>(3,3) ;
}


>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]