I would suggest looking up the man page for "free". Free is only called on memory allocated using commands such as "malloc", "calloc" or "realloc". Your use of it in this program is corrupting the process memory and making it coredump.
There are exactly 7 locations in your code, which could get the segmentation faults:
1)
Two locations at the code below:
Reason: Your decleration for str
Gives you only 1 column of 624 character locations; should be accessible in the code only at the zeroth row location only, like [I]str[0].
Soln: Either make sure that the value of J is not more than 0 and check for
or declare str like the following
This way you'd not get seg-11 at either of the 2 locations, described above.
2)
Five locations at the following code segments:
Reason:
You should use free() only on pointers, you explitly declared and defined in your program. That too, only when these pointers are pointing to a valid memory locations on the heap area of your program. Primarily once for every explicit call to malloc(), realloc(), calloc() only, however, sometimes you get a memory allocated through library function calls or some systems call (like stat()) for eg, but here too, such functions require you to pass a validly defined pointers to them.
You should NEVER call free() on any other things. Here you have called free() over a number of datatypes (which contain some numeric values which gets type casted implicitly to pointers to a memory locations which is definitely out of range of your process memory area. Hence getting segmentation faults.
Soln:
Remove the call to free() you do not require them in your program.
Cheers
Last edited by Praveen_218; 10-22-2010 at 08:42 AM..
Reason: Typo spelling errors :)
Hi,
thanks to a precedent post, and thanks to the reply of derekludwig of the forum, I have convert my first awk command as :
test.txt is : AAAAAGHIJKLAjKMEFJKLjklABCDJkLEFGHIJKL
awk -f findstring.awk test.txt > textreturn.txtfindstring.awk is :
BEGIN{ SLENGTH = 3 }
{
... (3 Replies)
Can anyone tell me why I keep getting a Segmentation fault when I try to run tilda?
$ tilda
Segmentation fault (core dumped)
It seemed to run after I deleted my tilda directory like this thread said to do. Unfortunately it wouldn't let me set my keybinding with anything I tried.
... (0 Replies)
When I was trying to mirror in my v880 server after OS up gradation from 8 to 10
metadb -afc 3 /dev/dsk/c1t1d0s7
I got an error
metadb: Segmentation Fault
Segmentation Fault (core dumped)
Then I logged a case to Oracle/sun team they suggest
"Please could you try
metadb -ac 3... (0 Replies)
I´m writing this program in QNX , I`m kinda new to UNIX and programing in general, and when I try to run it it gives me the Memory Fault error. Can anyone help?
#include <stdio.h>
#include <fcntl.h>
void main(void)
{int a,ter;
char buf;
printf("a=");
scanf("%d",a);
ter=open... (6 Replies)
Hi all,
I have a folder with some 28 files. I have a script file that will iteratively take one file at a time from the folder and provide an output for the input file. Till the 7th file, there was no problem but from the 8th file onwards, i got this Segmentation Fault(Core Dump) error. A file... (2 Replies)
Hi All,
I am getting "Segmentation fault (core dumped)" error in the runtime. I am new this please can you tell me why is that i am getting this error and I am not sure of my compilation :
gcc -c avc_test.c
gcc -c md5.c
gcc avc_test.o md5.o -shared -Llibcoreavc_sdk.so -o proj
... (1 Reply)
i am getting segmentation fault (core dumped)
i tried following things but couldn't understand what is wrong with my prog and where the problem is....
i have only adb debugger available on solaris....
so plz help
bash-3.00$ pstack core
core 'core' of 765: ./mod_generalised_tapinread... (4 Replies)
i am getting Segmentation Fault (core dumped) on solaris,
but when i run the same program with same input on linux it runs successfully.
How can i trace the fault in program on solaris. (6 Replies)
Hello To All!
Now anfd then I receive a message on my console:
Segmentation fault (core dumped)
What does it mean? Or more precisely what are the implications?
:confused: (1 Reply)