Hi. I'm having a few strange problems with malloc on a compile of a program I
Basically what's happening is malloc is causing a segmentation fault. The code
I wrote (and rewrote 4 different ways) passes in a size for a character array
(a size below 20, usually in the region of 8 to 10) to malloc, calling it as
array = (char *) malloc (strlen(s));
where is s another string I want to copy into the array. Using gdb, I traced
the program crash back and found that the size was being passed in correctly
to malloc from the program, but between __gnu_malloc and malloc.c, the size
got changed and the actual malloc.c malloc is being given a size of 0. I don't
know for sure if this is the reason it crashes, but it looks suspicious.
Interestingly enough, the same thing happens with four different versions of
the same code, some using new instead of malloc, trying it as a linked list,
trying it as a continually changing array, everything. It always crashes.
I have check the memory available each time. While there isn't always much
actual memory free, there's plenty of virtual memory. (32M total).
I have tried playing with different versions of the kernel I have lying around,
and different versions of the C libraries. Neither of these changes have done
anything. I'm currently working with kernel version 1.1.0, gcc 2.5.8 and the
library versions 4.5.21 or 4.5.26. Any help would be greatly appreciated!
C.Cruden (The llamas are coming!)
------ (The llamas are coming!)
"God help us all... we're in the hands of engineers."
- Ian Malcolm in the movie 'Jurassic Park'