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]

Bug/Memory Leak in <strstream>


Hi all,

I hope I'm correct under this email address. If not please forward the
mail.
While purifying one of my programs I found a leak in <strstream>.

My system:

SunOS giskard 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-1

Reading specs from
/opt/gnu/5.7/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)

/opt/purify-4.5-beta-L4-solaris2

Problemfile:
#include <strstream>

int main()
{
  int i;
  std::ostrstream OS;
  OS << "123" << '\0';
  std::istrstream IS(OS.str());
  IS >> i;
  std::cout << i << std::endl;
  return 0;
}

/*
      Memory leaked: 100 bytes (100%); potentially leaked: 0 bytes (0%)
         MLK: 100 bytes leaked at 0xc4c40
         This memory was allocated from:
               malloc         [rtlib.o]
               __bUiLtIn_nEw  [new1.cc:84]
               __builtin_new  [rtlib.o]
               __bUiLtIn_vEc_nEw [new2.cc:39]
                  #ifdef L_op_vnew
                  WEAK(void * operator new[] (size_t sz) throw
(std::bad_alloc))
                  {
               =>   return ::operator new(sz);
                  }
                  #endif

               __builtin_vec_new [rtlib.o]
               default_alloc(unsigned int) [strstream.cc:36]
         Purify Heap Analysis (combining suppressed and unsuppressed
blocks)

Leaking file: /opt/gnu_src/gcc-2.95.2-Solaris2.7/gcc/./cp/new2.cc
gcc version 2.95.2 19991024 (release)
*/

Compilecall:

g++  -c test.c
/opt/purify-4.5-beta-L4-solaris2/purify
-cache-dir=/tmp  g++  -o t test.o   -lm
Purify 4.5-beta-L4 990713 Solaris 2, Copyright (C) 1992-1999 Rational
Software Corp. All rights reserved.
Instrumenting: test.o  Linking

Please have look at the allocation in new2.cc and if there's a
corresponding deallocation missing

regards

Michael Seel


--
Michael.Seel@mpi-sb.mpg.de
MPI für Informatik, Saarbrücken, Germany
http://www.mpi-sb.mpg.de/~seel


begin:vcard 
n:Seel;Michael
tel;fax:49-681-9325-199
tel;work:49-681-9325-129
x-mozilla-html:FALSE
url:www.mpi-sb.mpg.de/~seel
org:MPI für Informatik;AG1
adr:;;;Saarbrücken;;;Germany
version:2.1
email;internet:seel@mpi-sb.mpg.de
title:Dipl.-Inform.
x-mozilla-cpt:;-4456
fn:Michael Seel
end:vcard

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