This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: GCC 3.2 Prerelease


On Tue, Aug 06, 2002 at 11:59:55AM -0700, H. J. Lu wrote:
> On Tue, Aug 06, 2002 at 11:37:00AM -0700, Joe Buck wrote:
> > 
> > FAIL: backward/strstream_members.cc execution test
> > 
> 
> gcc 3.3 with libstdc++.so.5.0.0 from gcc 3.2, I got
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x4207ad2d in free () from /lib/i686/libc.so.6
> (gdb) bt
> #0  0x4207ad2d in free () from /lib/i686/libc.so.6
> #1  0x4009f923 in operator delete(void*) (ptr=0x8000000)
>     at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_op.cc:39
> #2  0x4009f97f in operator delete[](void*) (ptr=0x8000000)
>     at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_opv.cc:36
> #3  0x400545a9 in std::strstreambuf::_M_free(char*) (this=0x8000000, 
>     p=0x8049c20 "")
>     at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/src/strstream.cc:325
> #4  0x40053e10 in ~strstreambuf (this=0xbffff604)
>     at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/src/strstream.cc:126
> #5  0x400554fc in ~ostrstream (this=0xbffff600)
>     at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/src/strstream.cc:380
> #6  0x080488f5 in test02() ()
>     at
> /home/hjl/work/gnu/src/gcc/gcc/libstdc++-v3/testsuite/backward/strstream_members.cc:41
> #7  0x08048918 in main ()
>     at
> /home/hjl/work/gnu/src/gcc/gcc/libstdc++-v3/testsuite/backward/strstream_members.cc:47
> #8  0x420175c9 in __libc_start_main () from /lib/i686/libc.so.6
> 
> After I set MALLOC_CHECK_=1, I got
> 
> free(): invalid pointer 0x8049c20!
> 
> Using libstdc++.so.5.0.0 from gcc 3.3, it ran fine.

I think the same memory got freed twice. The firt time:

Breakpoint 5, operator delete(void*) (ptr=0x8049c80)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_op.cc:39
39          free (ptr);
(gdb) bt
#0  operator delete(void*) (ptr=0x8049c80)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_op.cc:39
#1  0x400a197f in operator delete[](void*) (ptr=0x8049c80)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_opv.cc:36
#2  0x08048907 in test02() ()
    at
/home/hjl/work/gnu/src/gcc/gcc/libstdc++-v3/testsuite/backward/strstream_members.cc:41
#3  0x08048968 in main ()
    at
/home/hjl/work/gnu/src/gcc/gcc/libstdc++-v3/testsuite/backward/strstream_members.cc:47
#4  0x40120b88 in __libc_start_main (main=0x804894e <main>, argc=1, 
    ubp_av=0xbffff764, init=0x804861c <_init>, fini=0x80489a0 <_fini>, 
    rtld_fini=0x4000ba94 <_dl_fini>, stack_end=0xbffff75c)
    at ../sysdeps/generic/libc-start.c:129
(gdb) c

The second time:

Breakpoint 5, operator delete(void*) (ptr=0x8049c80)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_op.cc:39
39          free (ptr);
(gdb) bt
#0  operator delete(void*) (ptr=0x8049c80)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_op.cc:39
#1  0x400a197f in operator delete[](void*) (ptr=0x8049c80)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/libsupc++/del_opv.cc:36
#2  0x400565a9 in std::strstreambuf::_M_free(char*) (this=0x8049c80, 
    p=0x8049c80 "")
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/src/strstream.cc:325
#3  0x40055e10 in ~strstreambuf (this=0xbffff5f4)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/src/strstream.cc:126
#4  0x400574fc in ~ostrstream (this=0xbffff5f0)
    at /home/hjl/work/gnu/src/gcc-3.2/gcc/libstdc++-v3/src/strstream.cc:380
#5  0x08048945 in test02() ()
    at
/home/hjl/work/gnu/src/gcc/gcc/libstdc++-v3/testsuite/backward/strstream_
members.cc:41
#6  0x08048968 in main ()
    at
/home/hjl/work/gnu/src/gcc/gcc/libstdc++-v3/testsuite/backward/strstream_
members.cc:47
#7  0x40120b88 in __libc_start_main (main=0x804894e <main>, argc=1, 
    ubp_av=0xbffff764, init=0x804861c <_init>, fini=0x80489a0 <_fini>, 
    rtld_fini=0x4000ba94 <_dl_fini>, stack_end=0xbffff75c)
    at ../sysdeps/generic/libc-start.c:129
(gdb) 

I don't know if it is a compiler/library or ABI issue. It looks strange
to me:

int test02()
{
  std::ostrstream buf;
  buf << std::ends;
  char *s = buf.str ();
  delete [] s;
}

`s' has been deleted by test02. But strstreambuf::~strstreambuf does
it again. That is in gcc 3.2.


H.J.


H.J.


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