B
boltar2003
Hi
I don't know if this is a gcc C++ implementation issue (I suspect it is) or a
linux issue so I'm hedging my bets by posting to 2 newsgroups.
I have a C++ program for linux that does a LOT of recursion due to searching
etc which I won't bore you with but I am getting consistent crashes in the
STL. This appears to be due to running out of stack or heap space but all
that happens is the container crashes , there is no exception thrown and no way
of knowing when its going to happen. Sure I can limit recursion depth but
it would be nice to know when the stack limit is about to be hit.
So does anyone know a way in linux of checking the amount of stack space or
heap space left for a process (hopefully not something kludgy like attempting
to just malloc a large amount of memory to see what happens) or
is there a way to get around this apparent bug in the STL and make it chuck an
exception if this sort of thing happens?
There are 2 sorts of crashes I'm getting , one is a malloc() failure in new
(doesn't it check for NULL return from malloc??):
Program received signal SIGSEGV, Segmentation fault.
0xb76317e0 in malloc_consolidate () from /lib/libc.so.6
(gdb) bt
#0 0xb76317e0 in malloc_consolidate () from /lib/libc.so.6
#1 0xb76336e5 in _int_malloc () from /lib/libc.so.6
#2 0xb7635545 in malloc () from /lib/libc.so.6
#3 0xb7809d07 in operator new () from /usr/lib/libstdc++.so.6
#4 0x08058e68 in __gnu_cxx::new_allocator<cl_result*>::allocate (
this=0xbf435360, __n=128)
at /usr/lib/gcc/i486-slackware-linux/4.3.3/../../../../include/c++/4.3.3/
ext/new_allocator.h:92
#5 0x08058e92 in std::_Deque_base<cl_result*, std::allocator<cl_result*> >::
_M_allocate_node (this=0xbf435360)
and the other is something rather more obscure though probably related:
Program received signal SIGSEGV, Segmentation fault.
0x08057770 in std::__copy_move<false, false, std::random_access_iterator_tag>
::__copy_m<std::_Deque_iterator<cl_result*, cl_result* const&, cl_result*
const*>, std::_Deque_iterator<cl_result*, cl_result*&, cl_result**> >
(__first=
{_M_cur = 0x9c88b68, _M_first = 0x9c88b68, _M_last = 0x9c88d68, _M_node =
0x9c88464}, __last=
{_M_cur = 0x9c88b68, _M_first = 0x9c88b68, _M_last = 0x9c88d68, _M_node =
0x9c88464}, __result=
{_M_cur = 0xbf5dd088, _M_first = 0x0, _M_last = 0x0, _M_node =
0xbf5dd3c0})
at /usr/lib/gcc/i486-slackware-linux/4.3.3/../../../../include/c++/4.3.3/
bits/stl_algobase.h:340
340 for(_Distance __n = __last - __first; __n > 0; --__n)
Though the actual crash point varies.
Thanks for any help.
B2003
I don't know if this is a gcc C++ implementation issue (I suspect it is) or a
linux issue so I'm hedging my bets by posting to 2 newsgroups.
I have a C++ program for linux that does a LOT of recursion due to searching
etc which I won't bore you with but I am getting consistent crashes in the
STL. This appears to be due to running out of stack or heap space but all
that happens is the container crashes , there is no exception thrown and no way
of knowing when its going to happen. Sure I can limit recursion depth but
it would be nice to know when the stack limit is about to be hit.
So does anyone know a way in linux of checking the amount of stack space or
heap space left for a process (hopefully not something kludgy like attempting
to just malloc a large amount of memory to see what happens) or
is there a way to get around this apparent bug in the STL and make it chuck an
exception if this sort of thing happens?
There are 2 sorts of crashes I'm getting , one is a malloc() failure in new
(doesn't it check for NULL return from malloc??):
Program received signal SIGSEGV, Segmentation fault.
0xb76317e0 in malloc_consolidate () from /lib/libc.so.6
(gdb) bt
#0 0xb76317e0 in malloc_consolidate () from /lib/libc.so.6
#1 0xb76336e5 in _int_malloc () from /lib/libc.so.6
#2 0xb7635545 in malloc () from /lib/libc.so.6
#3 0xb7809d07 in operator new () from /usr/lib/libstdc++.so.6
#4 0x08058e68 in __gnu_cxx::new_allocator<cl_result*>::allocate (
this=0xbf435360, __n=128)
at /usr/lib/gcc/i486-slackware-linux/4.3.3/../../../../include/c++/4.3.3/
ext/new_allocator.h:92
#5 0x08058e92 in std::_Deque_base<cl_result*, std::allocator<cl_result*> >::
_M_allocate_node (this=0xbf435360)
and the other is something rather more obscure though probably related:
Program received signal SIGSEGV, Segmentation fault.
0x08057770 in std::__copy_move<false, false, std::random_access_iterator_tag>
::__copy_m<std::_Deque_iterator<cl_result*, cl_result* const&, cl_result*
const*>, std::_Deque_iterator<cl_result*, cl_result*&, cl_result**> >
(__first=
{_M_cur = 0x9c88b68, _M_first = 0x9c88b68, _M_last = 0x9c88d68, _M_node =
0x9c88464}, __last=
{_M_cur = 0x9c88b68, _M_first = 0x9c88b68, _M_last = 0x9c88d68, _M_node =
0x9c88464}, __result=
{_M_cur = 0xbf5dd088, _M_first = 0x0, _M_last = 0x0, _M_node =
0xbf5dd3c0})
at /usr/lib/gcc/i486-slackware-linux/4.3.3/../../../../include/c++/4.3.3/
bits/stl_algobase.h:340
340 for(_Distance __n = __last - __first; __n > 0; --__n)
Though the actual crash point varies.
Thanks for any help.
B2003