Package: libstdc++5-3.3-dev Version: 1:3.3.1-0pre0 Severity: normal Tags: upstream
Hi, I think I've found a bug in the allocation of strings done by the standard c++ library. Maybe you are already aware of it, but I thought it might be useful to report it. This small testcase: ------------------- #include <string> int main(int argc, char* argv[]) { std::string stars = "*************"; return 0; } Is reported to have leaks with three different leak analyzers: leaktracer (2.4-1.0) Gathered 1 (1 unique) points of data. (gdb) #-- Leak: counted 1x / total Size: 1280 No source file for address 0x400a7efb. ccmalloc (0.4.0-2.0) (...) .---------------. |ccmalloc report| ======================================================= | total # of| allocated | deallocated | garbage | +-----------+-------------+-------------+-------------+ | bytes| 1280 | 0 | 1280 | +-----------+-------------+-------------+-------------+ |allocations| 1 | 0 | 1 | +-----------------------------------------------------+ (...) *100.0% = 1280 Bytes of garbage allocated in 1 allocation | | | | 0x40121da6 in <???> | | | | 0x080490b5 in <main> (...) valgrind (20031012) (...) ==19195== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==19195== malloc/free: in use at exit: 1280 bytes in 1 blocks. ==19195== malloc/free: 1 allocs, 0 frees, 1280 bytes allocated. ==19195== ==19195== searching for pointers to 1 not-freed blocks. ==19195== checked 4562000 bytes. ==19195== ==19195== 1280 bytes in 1 blocks are still reachable in loss record 1 of 1 ==19195== at 0x4002CAFD: __builtin_new (vg_replace_malloc.c:172) ==19195== by 0x4002CB68: operator new(unsigned) (vg_replace_malloc.c:185) ==19195== by 0x402CEEFA: std::__default_alloc_template<true,0>::_S_chunk_alloc(unsigned, int&) (in /usr/lib/libstdc++.so.5.0.5) ==19195== by 0x402CEE0C: std::__default_alloc_template<true,0>::_S_refill(unsigned) (in /usr/lib/libstdc++.so.5.0.5) ==19195== ==19195== LEAK SUMMARY: ==19195== definitely lost: 0 bytes in 0 blocks. ==19195== possibly lost: 0 bytes in 0 blocks. ==19195== still reachable: 1280 bytes in 1 blocks. ==19195== suppressed: 0 bytes in 0 blocks. (...) Testing with other string constructors, such as string stars(10, '*'); or passing a string as a parameter to a procedure, gives the same results, while using the empty constructor (string stars;) shows no leak at all. At first I thought this might be a problem of the leak analyzers, but 3 analyzers having the same problem seems a bit too much. I consulted some other programmers, and all agreed that this really looked as a bug in the standard library. I hope you can have a look at it. Love, Margarita Manterola -- System Information: Debian Release: testing/unstable Architecture: i386 Kernel: Linux hormiga.amadeus 2.4.19-686 #1 Mon Nov 18 23:59:03 EST 2002 i686 Locale: LANG=es_AR, LC_CTYPE=es_AR Versions of packages libstdc++5-3.3-dev depends on: ii g++-3.3 1:3.3.1-0pre0 The GNU C++ compiler ii gcc-3.3-base 1:3.3.1-0pre0 The GNU Compiler Collection (base ii libc6-dev 2.3.2.ds1-10 GNU C Library: Development Librari ii libstdc++5 1:3.3.2-4 The GNU Standard C++ Library v3 -- no debconf information