Why do I get a SIGSEGV?

Why I am getting a runtime error SIGSEGV in the problem? Where I am going wrong?

13 Likes

This is an error caused by an invalid memory reference or segmentation fault. The most common causes are accessing an array element out of bounds, or using too much memory.

Some things for you to try:

Make sure you aren’t using variables that haven’t been initialised. These may be set to 0 on your computer, but aren’t guaranteed to be on the judge.

Check every single occurrence of accessing an array element and see if it could possibly be out of bounds.

Make sure you aren’t declaring too much memory. 64 MB is guaranteed, but having an array of size [10000][10000] will never work.

Make sure you aren’t declaring too much stack memory. Any large arrays should be declared globally, outside of any functions - putting an array of 100000 ints inside a function probably won’t work.

47 Likes

//why i was getting SIGSEGV??
//for this question http://www.codechef.com/COQU2014/problems/DCQ1402
//please help n explain

for this solution http://www.codechef.com/viewsolution/5277974

1 Like

why do i get SIGSEV for the problem http://www.codechef.com/KAN14ROL/problems/ACM14KN3/

solution is http://www.codechef.com/viewsolution/5456719

why am i getting sigsev for the solution at http://www.codechef.com/viewsolution/5601458

1 Like

can anyone help m why m getting SIGSEGV RUNTIME ERROR http://www.codechef.com/viewsolution/5940071

why di i get reutime error for given problem
#include<stdio.h>
#include<stdlib.h>
#define size 65535
int main()
{
long n,k,j,t[size],i=0,count=0;
scanf("%ld %ld",&n,&k);
while(i<n)
{
scanf("%ld",&t[i]);
printf("\n");
if(t[i]%k==0)
count++;
i++;
}
printf("%ld\n",count);
}

please help why do i get sigsegv in this code http://www.codechef.com/viewsolution/5988352

why do i get SIGSEVG

why am i getting SIGSEVG ?
http://www.codechef.com/viewsolution/6144778
plz help

why am i getting SIGEVG?http://www.codechef.com/viewsolution/6153699
please help

can anyone help me…why i am getting SIGSEVG error in this http://ideone.com/PeQwg9
thanks in advance

can anyone help me…why i am getting SIGSEVG error in this http://ideone.com/PeQwg9
thanks in advance

#include<stdio.h>
main()
{
long long t=0,i=0,j=0,temp=0,a[10000];
scanf("%lld",&t);
for(i=0;i<t;i++)
scanf("%lld",&a[i]);

for(i=0;i<t-1;i++)
{
	for(j=0;j<t-1;j++)
	{
		if(a[j]>a[j+1])
        {
        temp=a[j];
		a[j]=a[j+1];
		a[j+1]=temp;
	    }
   }
}
for(i=0;i<t;i++)
  printf("%lld\n",a[i]);

}

why am i getting SIGSEVG ? http://www.codechef.com/viewsolution/6368752 plzzzzz help me!! Thank U…

A segfault basically means you did something bad with pointers. This is probably a segfault:

char *c = NULL;

*c; // dereferencing a NULL pointer
Or this:

char *c = “Hello”;

c[10] = ‘z’; // out of bounds, or in this case, writing into read-only memory
Or maybe this:

char *c = new char[10];

delete [] c;

c[2] = ‘z’; // accessing freed memory
Same basic principle in each case - you’re doing something with memory that isn’t yours.

Hi Folks,
Check out the latest Coding jobs :- http://jobsiit.com/jobs/listing/Computer%20Science

Adobe Systems is hiring Software Engineers
CTC:- 8-30 Lac, Exp:- 0-8 Years, Bangalore

Apply Here:- http://jobsiit.com/jobs/view/1876/Adobe-Systems/Software-Engineer

Why do I get SIGSEGV error for this code http://www.codechef.com/viewsolution/6382701