This is the mail archive of the gcc-bugs@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]

version 1.0.2 under IRIX 6.3


Hi,

I have compiled the latest release of egcs (1.0.2) under IRIX 6.3 and
am testing out a simple program to read a character from a file.  It
dies with a SIGSEGV violation.  The code I'm testing is:

#include <fstream.h>
#include <iostream.h>

const char *filename = "testfile";

int 
main()
{             
  ifstream    in_file(filename);

  cout << in_file.get() << endl;
  return (0);
}

It was compiled with:

../gcc/g++ -B../gcc/ -I../../libio -L../libraries/libio -L../libraries/libstdc++
-v -g -o test test.cc
Reading specs from ../gcc/specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
 ../gcc/cpp -lang-c++ -v -I../../libio -isystem ../gcc/include -undef
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dunix -Dmips -Dsgi
-Dhost_mips -DMIPSEB -D_MIPSEB -DSYSTYPE_SVR4 -D_LONGLONG -D_SVR4_SOURCE
-D_MODERN_C -D__DSO__ -D__unix__ -D__mips__ -D__sgi__ -D__host_mips__
-D__MIPSEB__ -D_MIPSEB -D__SYSTYPE_SVR4__ -D_LONGLONG -D_SVR4_SOURCE -D_MODERN_C
-D__DSO__ -D__unix -D__mips -D__sgi -D__host_mips -D__MIPSEB -D__SYSTYPE_SVR4
-Asystem(unix) -Asystem(svr4) -Acpu(mips) -Amachine(sgi) -D__EXCEPTIONS
-D__CHAR_UNSIGNED__ -g -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS
-D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D__EXTENSIONS__
-D_SGI_SOURCE -D_MIPS_FPSET=32 -D_MIPS_ISA=_MIPS_ISA_MIPS3 -D_ABIN32=2
-D_MIPS_SIM=_ABIN32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32
-D_COMPILER_VERSION=601 -U__mips -D__mips=3 -D__mips64 test.cc
/var/tmp/cca001Jc.ii
GNU CPP version egcs-2.90.27 980315 (egcs-1.0.2 release) [AL 1.1, MM 40] SGI
running IRIX 6.x
#include "..." search starts here:
#include <...> search starts here:
 ../../libio
 ../gcc/include
 /usr/local/include/g++
 /usr/local/lib/g++-include
 /usr/local/include
 /usr/local/mips-sgi-irix6.3/include
 /usr/include
End of search list.
 ../gcc/cc1plus /var/tmp/cca001Jc.ii -quiet -dumpbase test.cc -g -version -o
/var/tmp/cca001Jc.s
GNU C++ version egcs-2.90.27 980315 (egcs-1.0.2 release) (mips-sgi-irix6.3)
compiled by GNU C version egcs-2.90.27 980315 (egcs-1.0.2 release).
 as -g0 -nocpp -show -G 0 -w -n32 -o /var/tmp/cca001Jc1.o /var/tmp/cca001Jc.s
/usr/lib32/cmplrs/as -g0 -nocpp -show -G 0 -w -n32 -o /var/tmp/cca001Jc1.o
/var/tmp/cca001Jc.s
/usr/lib32/cmplrs/asm -EB -O0 -pic2 -elf -g0 -G0 -w -mips3 -n32 -t5_ll_sc_bug
/var/tmp/cca001Jc.s -o /var/tmp/cca001Jc1.o 
 ../gcc/ld -call_shared -no_unresolved -init __do_global_ctors -fini
__do_global_dtors -_SYSTYPE_SVR4 -n32 -o test /usr/lib32/mips3/crt1.o
-L/usr/lib32/mips3 -L/usr/lib32 ../gcc/crtbegin.o -L../libraries/libio
-L../libraries/libstdc++ -L../gcc -L/usr/local/mips-sgi-irix6.3/lib
-L/usr/local/lib /var/tmp/cca001Jc1.o -lstdc++ -lm -dont_warn_unused -lgcc
-warn_unused -dont_warn_unused -lc -warn_unused -dont_warn_unused -lgcc
-warn_unused ../gcc/crtend.o /usr/lib32/mips3/crtn.o


The file being read in can be any simple text file.  Here is the dump
from dbx:

beeper% dbx test core
dbx version 7.1 Dec  3 1996 17:03:19
Core from signal SIGSEGV: Segmentation violation
(dbx) where
>  0 istream::get(this = 0x7fff2ed0) ["/net/hc280/develop/karenb/egcs-1.0.2/
objdir/libraries/libio/../../../libio/streambuf.h":217, 0x10017da4]
   1 ::main() ["/net/hc280/develop/karenb/egcs-1.0.2/objdir/test/test.cc":14,
0x1000961c]
   2 __start() ["/xlv3/bonsai-oct28/work/irix/lib/libc/libc_n32_M3/csu/
crt1text.s":166, 0x1000949c]
(dbx) 


If you step through the code it looks like the variable 'in_file' is not
getting constructed correctly.  If you look at 'in_file' after it is
created:

(dbx) p in_file
struct ifstream {
-----------fstreambase------------
    _strbuf = 0x7fff2ee8
    _tie = 0x1700
    _width = -72539000
    _flags = 0
    _fill = 0
    _state = ''
    _exceptions = ''
    _precision = 0
    _arrays = (nil)
    _vptr$ios = (nil)
    _vb$ios = 0x7fff2ee8
    __my_fb = struct filebuf {
        _flags = 5888
        _IO_read_ptr = 0xfbad2488
        _IO_read_end = (nil)
        _IO_read_base = (nil)
        _IO_write_base = (nil)
        _IO_write_ptr = (nil)
        _IO_write_end = (nil)
        _IO_buf_base = (nil)
        _IO_buf_end = (nil)
        _IO_save_base = (nil)
        _IO_backup_base = (nil)
        _IO_save_end = (nil)
        _markers = (nil)
        _chain = (nil)
        _fileno = 268677344
        _blksize = 3
        _offset = -2119368704
        _cur_column = 65535
        _unused = '\377'
        _shortbuf = "\377"
        _vptr$streambuf = 0xffffffff
    }
----------istream------------
    _strbuf = 0x80d6
    _tie = (nil)
    _width = 268676264
    _flags = 4
    _fill = 32767
    _state = '.'
    _exceptions = '\350'
    _precision = 0
    _arrays = 0x7fff2e88
    _vptr$ios = (nil)
    _vb$ios = 0x80d6
    _gcount = 0


You can see the second "ios" class from class istream is not initialized
properly.  I've run this same code under SunOS compiled with version 
2.8.0 of g++ (not egcs) and it works fine.  The only difference I can see
is the second "ios" structure is correctly initialized (used gdb under
SunOS):

(gdb) p in_file
$1 = {<fstreambase> = {<ios> = {<_ios_fields> = {_strbuf = 0xf7fffa24, 
        _tie = 0x0, _width = 0, _flags = 17, _fill = 32, _state = 0 '\000', 
        _exceptions = 0 '\000', _precision = 6, _arrays = 0x0}, 
      _vptr$ = 0x1c2b0 <ifstream::ios virtual table>}, _vb$ios = 0xf7fffa78, 
    __my_fb = {<streambuf> = {<_IO_FILE> = {_flags = -72539000, 
          _IO_read_ptr = 0x0, _IO_read_end = 0x0, _IO_read_base = 0x0, 
          _IO_write_base = 0x0, _IO_write_ptr = 0x0, _IO_write_end = 0x0, 
          _IO_buf_base = 0x0, _IO_buf_end = 0x0, _IO_save_base = 0x0, 
          _IO_backup_base = 0x0, _IO_save_end = 0x0, _markers = 0x0, 
          _chain = 0x1e68c, _fileno = 3, _blksize = -134219072, _offset = -1, 
          _cur_column = 0, _unused = 0 '\000', _shortbuf = ""}, 
        static _list_all = <optimized out>, 
        _vptr$ = 0x1d470 <filebuf virtual table>}, 
      static openprot = 420}}, <istream> = {<ios> = {<_ios_fields> = {
        _strbuf = 0xf7fffa24, _tie = 0x0, _width = 0, _flags = 17, _fill = 32, 
        _state = 0 '\000', _exceptions = 0 '\000', _precision = 6, 
        _arrays = 0x0}, _vptr$ = 0x1c2b0 <ifstream::ios virtual table>}, 
    _vb$ios = 0xf7fffa78, _gcount = 0}, }

Maybe my dbx under IRIX 6.3 is lying to me but since I'm getting a
segmentation violation, I'm assuming I have an uninitialized variable.
Does anyone have any suggestions on what's wrong?  

Thanks,
--Karen

--
Karen Carter (karenb@cc.gatech.edu)		Georgia Institute of Technology
Computing and Networking Services		Atlanta, Georgia 30332-0280
College of Computing				(404) 894-9301  office: 223


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