|
From: Bart V. A. <bar...@gm...> - 2006-08-24 09:17:05
|
Hello,
While using memcheck I always get the message included below during
application startup. Anyone any idea whether it's a libstdc++ issue or a
memcheck issue ? I don't think it's due to the application.
Details: MontaVista Linux Professional 4.0.1 / glibc 2.3.3 / libstdc++6
3.4.3 / gcc 3.4.3 / g++ 3.4.3
memcheck report:
==4344== Thread 3:
==4344== Invalid read of size 4
==4344== at 0xFC3EBB0: (within /lib/libc-2.3.3.so)
==4344== Address 0x78A9C54 is 84 bytes inside a block of size 87 alloc'd
==4344== at 0xFFBACA0: operator new(unsigned) (vg_replace_malloc.c:163)
==4344== by 0xFE9C8F0: std::string::_Rep::_S_create(unsigned, unsigned,
std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.3)
==4344== by 0xFE9C988: std::string::_Rep::_M_clone(std::allocator<char>
const&, unsigned) (in /usr/lib/libstdc++.so.6.0.3)
==4344== by 0xFE9D0C0: std::string::reserve(unsigned) (in
/usr/lib/libstdc++.so.6.0.3)
==4344== by 0xFE9DD94: std::string::append(std::string const&) (in
/usr/lib/libstdc++.so.6.0.3)
==4344== by 0x10037730: std::basic_string<char, std::char_traits<char>,
std::allocator<char> > std::operator+<char, std::char_traits<char>,
std::allocator<char> >(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&) (basic_string.h:1993)
>From bits/basic_string.h:
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::_Rep*
basic_string<_CharT, _Traits, _Alloc>::_Rep::
_S_create(size_type __capacity, size_type __old_capacity,
const _Alloc& __alloc)
{
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
if (__capacity > _S_max_size)
__throw_length_error(__N("basic_string::_S_create"));
const size_type __pagesize = 4096; // must be 2^i * __subpagesize
const size_type __subpagesize = 128; // should be >>
__malloc_header_size
const size_type __malloc_header_size = 4 * sizeof (void*);
const size_type __page_capacity = ((__pagesize - __malloc_header_size
- sizeof(_Rep) - sizeof(_CharT))
/ sizeof(_CharT));
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity
&& __capacity > __page_capacity)
__capacity = 2 * __old_capacity;
size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
const size_type __adj_size = __size + __malloc_header_size;
if (__adj_size > __pagesize)
{
const size_type __extra = __pagesize - __adj_size % __pagesize;
__capacity += __extra / sizeof(_CharT);
// Never allocate a string bigger than _S_max_size.
if (__capacity > _S_max_size)
__capacity = _S_max_size;
__size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
}
else if (__size > __subpagesize)
{
const size_type __extra = __subpagesize - __adj_size %
__subpagesize;
__capacity += __extra / sizeof(_CharT);
__size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
}
void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
_Rep *__p = new (__place) _Rep;
__p->_M_capacity = __capacity;
__p->_M_set_sharable(); // One reference.
__p->_M_length = 0;
return __p;
}
|