 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Joakim Hove Guest
|
Posted: Mon May 07, 2007 9:12 am Post subject: SIGSEGV in malloc() |
|
|
Hello,
in my application I have a typedefed struct:
typedef struct {
double d1;
int i1;
/* I have simplified the object here. */
} data_ptr_type;
I allocate storage for such object many times in my application, and
at some point in time (repeatedly at the same spot, but seemingly
random to me), the application fails with a SIGSEGV at:
data_ptr_type * data = malloc(sizeof *data);
To me it seems quite illogical that the malloc implementation should
be able to die with a SIGSEGV(?) - either it should return a pointer
to freshly allocated storage, or if that is not possible it should
return NULL. Can this be a sign of a bug in the malloc()
implementation - I know that sounds unlikely but??
My system is:
RedHat Enterprise Linux
gcc-3.4.6
64 bit computer, but comiled with -m32 switch.
Any suggestions?
Regards Joakim |
|
| Back to top |
|
 |
Richard Heathfield Guest
|
Posted: Mon May 07, 2007 9:12 am Post subject: Re: SIGSEGV in malloc() |
|
|
Joakim Hove said:
<snip>
| Quote: | I allocate storage for such object many times in my application, and
at some point in time (repeatedly at the same spot, but seemingly
random to me), the application fails with a SIGSEGV at:
data_ptr_type * data = malloc(sizeof *data);
To me it seems quite illogical that the malloc implementation should
be able to die with a SIGSEGV(?) -
|
It's impossible to say for sure without seeing the code, but it's my
guess that you've probably done one of these three things:
1) free(p); ..... later, you used this indeterminate pointer value - OR
2) free(p); ..... later, free(p); - OR
3) p = malloc(sizeof *p); if(p != NULL) { modify(&p) somehow; free(p); }
Like I said, I'm just guessing really (because I can't see the code),
but any of the above could explain why your malloc arena is stuffed.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|