Suspicious C++ stringstream crashes, gcc 3.3.3

Andrew Walrond
Mon May 24 13:18:00 GMT 2004

Are there any known stringstream problems in 3.3.3? I have a reproducible 
crash which seems to scribble on the stack and causes a segfault. Bugzilla 
searches haven't thrown up anything useful.

Usual story; If I put in debug code, it goes away, so I haven't been able to 
isolate a small test case. But I am now pretty convinced that the problem 
lies here.

This is the suspect code snippet, which simply creates a hex string from some 
ostringstream _HexDigest;
_HexDigest << hex << setfill('0') << internal;
for (int i=0; i<SHA_DIGEST_LENGTH; i++)
	_HexDigest << setw(2) << (unsigned)mBytes[i];

In gdb it looks like this:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 2377)]
0x40298b1c in memcpy () from /pkg/glibc.1/lib/
(gdb) bt
#0  0x40298b1c in memcpy () from /pkg/glibc.1/lib/
#1  0x400728d4 in std::__pad<char, std::char_traits<char> 
>::_S_pad(std::ios_base&, char, char*, char const*, int, int, bool) ()
   from /lib/gcc-lib/i686-pc-linux-gnu/3.3.3/
#2  0x40072a84 in std::num_put<char, std::ostreambuf_iterator<char, 
std::char_traits<char> > >::_M_pad(char, int, std::ios_base&, char*, char 
const*, int&) const () 
from /lib/gcc-lib/i686-pc-linux-gnu/3.3.3/
#3  0x40073b50 in std::ostreambuf_iterator<char, std::char_traits<char> > 
std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > 
>::_M_convert_int<unsigned long>(std::ostreambuf_iterator<char, 
std::char_traits<char> >, std::ios_base&, char, unsigned long) const ()
   from /lib/gcc-lib/i686-pc-linux-gnu/3.3.3/
#4  0xa3a10000 in ?? ()
(gdb) info args
No symbol table info available.

Please let me know if this rings any bells

Andrew Walrond

More information about the Gcc mailing list