gcc 2.96, libstdc++ v3 and efence

Maurizio Umberto Puxeddu umbpux@tin.it
Mon Aug 21 05:34:00 GMT 2000

This a testcase that trigger the bug without using efence (at least I
think it is the same bug):

#include <iostream>
#include <stdlib.h>

void *
operator new(size_t m)
  std::cout << "new" << std::endl;
  return malloc(m);

operator delete(void *p)
  std::cout << "delete" << std::endl;


  int *p = new int;
  delete [] p;

  return 0;

If I enable cout messages inside the new and delete operators the
program will segfault with this stack trace:

Program received signal SIGSEGV, Segmentation fault.
std::basic_ostream<char, std::char_traits<char> >::sentry::sentry (
    this=0xbffff34c, __os=@0x8049f68)
    at ../../../../gcc/libstdc++-v3/bits/basic_ios.h:98
98            { return _M_streambuf_state; }
(gdb) bt
#0  std::basic_ostream<char, std::char_traits<char> >::sentry::sentry (
    this=0xbffff34c, __os=@0x8049f68)
    at ../../../../gcc/libstdc++-v3/bits/basic_ios.h:98
#1  0x400b6267 in std::basic_ostream<char, std::char_traits<char> > &
std::operator<<<std::char_traits<char> > (__out=@0x8049f68,
__s=0x8048d24 "new")
    at ../../../../gcc/libstdc++-v3/bits/std_ostream.h:635
#2  0x8048b00 in __builtin_new (m=24) at prova.cc:8
#3  0x4007c49d in std::locale::classic ()
    at ../../../../gcc/libstdc++-v3/src/locale.cc:336
#4  0x4009839d in std::basic_filebuf<char, std::char_traits<char>
>::basic_filebuf (this=0x400e8f00) at ../../../../gcc/libstdc++-v3/bits/localefwd.h:302
#5  0x40077ec6 in __static_initialization_and_destruction_0
    __priority=65535) at
#6  0x400785a2 in global constructors keyed to std::__cfileinit ()
    at ../../../../gcc/libstdc++-v3/bits/std_fstream.h:96
#7  0x40074f95 in __do_global_ctors_aux () at
#8  0x40064a52 in ?? () from /usr/local2/lib/libstdc++.so.3

Hope this helps.

Maurizio Umberto Puxeddu

More information about the Libstdc++ mailing list