J
Josh
I have a segmentation fault, and gdb says that the problem is in the
line:
buffer+=(s+' ');
inside the + operator. "buffer" and "s" are both C++ strings. When I
print out
buffer.c_str() and s.c_str() in gdb, I get ordinary strings ... no
null pointers are evident.
The line runs just fine many times in a row, and then mysteriously
fails.
I have pasted in the backtrace from gdb below, up to the point where
it reaches the + operator.
Is it possible that the program is just running out of memory? And if
so, how would I test that? Any other ideas as to what could cause
this? Is there any other useful information I should provide? Thanks
-
#0 std::__default_alloc_template<true, 0>::allocate (__n=41)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/stl_alloc.h:417
#1 0xff15ab8c in std::string::_Rep::_S_create (__capacity=21,
__alloc=@0xffbbd428)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/stl_alloc.h:673
#2 0xff15ac84 in std::string::_Rep::_M_clone (this=0x25b6b0,
__alloc=@0xffbbd428, __res=1)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/basic_string.tcc:582
#3 0xff158fdc in std::string::reserve (this=0xffbbd5b8,
__res=4290499624)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/basic_string.h:408
#4 0xff1593f4 in std::string::append (this=0xffbbd5b8, __n=1, __c=32
' ')
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/basic_string.tcc:718
#5 0x000ba8b8 in std:
perator+<char, std::char_traits<char>,
std::allocator<char> > (__lhs=@0xffbbd5e0, __rhs=32 ' ')
line:
buffer+=(s+' ');
inside the + operator. "buffer" and "s" are both C++ strings. When I
print out
buffer.c_str() and s.c_str() in gdb, I get ordinary strings ... no
null pointers are evident.
The line runs just fine many times in a row, and then mysteriously
fails.
I have pasted in the backtrace from gdb below, up to the point where
it reaches the + operator.
Is it possible that the program is just running out of memory? And if
so, how would I test that? Any other ideas as to what could cause
this? Is there any other useful information I should provide? Thanks
-
#0 std::__default_alloc_template<true, 0>::allocate (__n=41)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/stl_alloc.h:417
#1 0xff15ab8c in std::string::_Rep::_S_create (__capacity=21,
__alloc=@0xffbbd428)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/stl_alloc.h:673
#2 0xff15ac84 in std::string::_Rep::_M_clone (this=0x25b6b0,
__alloc=@0xffbbd428, __res=1)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/basic_string.tcc:582
#3 0xff158fdc in std::string::reserve (this=0xffbbd5b8,
__res=4290499624)
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/basic_string.h:408
#4 0xff1593f4 in std::string::append (this=0xffbbd5b8, __n=1, __c=32
' ')
at /usr2/SOURCES/S9/gcc-3.3.2/objdir/sparc-sun-solaris2.9/libstdc+
+-v3/include/bits/basic_string.tcc:718
#5 0x000ba8b8 in std:
std::allocator<char> > (__lhs=@0xffbbd5e0, __rhs=32 ' ')