new () keeps core-dump instead of generating exception

W

wenmang

Hi, all,

I am trying to allocate some objects during application starts up. The
objects are created through new operator, but for some reason, the
application keeps crashing and here is the debug trace:
(gdb) where
#0 0xb64349dd in _int_malloc () from /lib/tls/libc.so.6
#1 0xb6433ced in malloc () from /lib/tls/libc.so.6
#2 0xb659789e in operator new () from /usr/lib/libstdc++.so.5

I am using redhat Linux 2.4.21-15.ELsm, any idea why is that?
 
D

David Côme

Hi, all,

I am trying to allocate some objects during application starts up. The
objects are created through new operator, but for some reason, the
application keeps crashing and here is the debug trace:
(gdb) where
#0 0xb64349dd in _int_malloc () from /lib/tls/libc.so.6
#1 0xb6433ced in malloc () from /lib/tls/libc.so.6
#2 0xb659789e in operator new () from /usr/lib/libstdc++.so.5

I am using redhat Linux 2.4.21-15.ELsm, any idea why is that?


Without some code, we can't help you .
 
E

Erik Wikström

Hi, all,

I am trying to allocate some objects during application starts up. The
objects are created through new operator, but for some reason, the
application keeps crashing and here is the debug trace:
(gdb) where
#0 0xb64349dd in _int_malloc () from /lib/tls/libc.so.6
#1 0xb6433ced in malloc () from /lib/tls/libc.so.6
#2 0xb659789e in operator new () from /usr/lib/libstdc++.so.5

In addition to what David said:

Either you have a bad version of libc (not likely) or the problem is in
stack-frame not shown in the above backtracer, find the stack-frame
which is in your code and start looking there.
 
K

kasthurirangan.balaji

In addition to what David said:

Either you have a bad version of libc (not likely) or the problem is in
stack-frame not shown in the above backtracer, find the stack-frame
which is in your code and start looking there.

as said by others, we need some code as to what/where/how you are
using new. Anyways, new should throw an exception on failure. my guess
is that are you catching the bad allocation exception??
for genericity you may use catch(...) as uncaught exceptions tend to
dump core, atleast in the platforms i have used(aix & sun).

Thanks,
Balaji.
 
J

James Kanze

I am trying to allocate some objects during application starts up. The
objects are created through new operator, but for some reason, the
application keeps crashing and here is the debug trace:
(gdb) where
#0 0xb64349dd in _int_malloc () from /lib/tls/libc.so.6
#1 0xb6433ced in malloc () from /lib/tls/libc.so.6
#2 0xb659789e in operator new () from /usr/lib/libstdc++.so.5
I am using redhat Linux 2.4.21-15.ELsm, any idea why is that?

Any idea as to why you're using redhat Linux, no.

If you meant why you're crashing, it's impossible to say, but in
general, supposing that you've linked in the right versions of
everything, it's probable that you've mucked up the free store
arena with some illegal memory writes earlier. (Or, as someone
else suggested, you've requested more memory than is available,
and aren't catching the exception---and possibly cannot catch
it, if you're still running static initializers.)
 
S

Shobhit Gupta

Two things you can try:
1. As suggested by Balaji above, use catch(...)

2. Use the "nothrow" version of new:
e.g.
int *i = new (nothrow) int[10];
if(i==NULL)
{
cout << "see if it comes here" << endl;
}
 
J

James Kanze

Two things you can try:
1. As suggested by Balaji above, use catch(...)

Where? He said that it was during program start-up, which I
understand to mean before main.
2. Use the "nothrow" version of new:
e.g.
int *i = new (nothrow) int[10];
if(i==NULL)
{
cout << "see if it comes here" << endl;
}

If new is crashing, then that probably won't change anything.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top