Why do I get a SIGSEGV?

You can check here for all errors that mostly occurs at codechef https://www.codechef.com/wiki/status-codes

SIGSEGV : A SIGSEGV is an error(signal) caused by an invalid memory reference or a segmentation fault. You are probably trying to access an array element out of bounds or trying to use too much memory. Some of the other causes of a segmentation fault are : Using uninitialized pointers, dereference of NULL pointers, accessing memory that the program doesn’t own

@gokul95
“solution is http://www.codechef.com/viewsolution/5456719

You are getting SIGSEGV becuase you have take character pointer char* a and inputting directly into “a” by using scanf("%s",a); This is wrong. “a” is a pointer and has no memory alocated to it. You should first allocate memory to the pointer using malloc before taking inout.
a=(char* )malloc(sizeof(char)*SIZE)
where SIZE is the maximum input lenght of string + 1(1 extra for ‘\0’).
Just add this line before your scanf line.

I have tried many things and this code runs fine on my computer but on submitting I repeatedly get SIGSSEVG ?? You can check here.https://www.codechef.com/viewsolution/10845863

why do i get sigsevg for this code
https://www.codechef.com/viewsolution/11028794

why do i get sigsevg for the code : https://www.codechef.com/viewsolution/11028794

Go to Help—> FAQ
You get most of your answer there.

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.

As [wikipedia][1] says

“It is an fault raised by hardware informing your operating system about memory access violation , for which os kernel in return generate a signal to the offending process , called SIGSEGV (or Core dumped).”

But in simple terms

"These errors are generated if any pointer(like in C language that provide low level memory access) is trying to access a memory location which has not been allocated to the program , or your program is trying to use memory which are not for the program "
[1]: https://en.wikipedia.org/wiki/Segmentation_fault

getting runtime SIGSEVG on this, don’t know why

https://www.codechef.com/viewsolution/11194997

U can declare a array of size [10000][10000] globally . and it will not give sigsegv error

why am i getting SIGSEV for this solution?

https://www.codechef.com/viewsolution/11203458.

what can i really do in order to remove it?

i am getting sigsegv in this code https://www.codechef.com/viewsolution/11221046
for this problem https://www.codechef.com/problems/TSORT
pls help

#include<stdio.h>
#include<stdlib.h>
int main(int argc,char * argv[])
{
int i,j,m, T,reverse=0;
// int arr[200];
int n[200];
T=atoi(argv[1]) ;
if(!((1<=T)&&(T<=1000)))
{
exit(0); //checking if T is not greater than 1000 and not less than 1
}
for(i=0,j=2;j<T+2;i++,j++)
{
n[i] = atoi(argv[j]) ;
if(!((1<=n[i])&&(n[i]<=100000) )) //checking if n is not greater than 100000 and not less than 1
{
exit(0); //(0 <= i) && ( i<=10)
}
}
/* printf("%d\n",T);

for(m=0;m<T;m++)
{
printf("%d\n",n[m]);
}
*/

for (m=0;m<T;m++)
 {
     reverse=0;
     while(n[m] != 0)
  {
  	 reverse = reverse * 10;
  	 reverse = reverse + (n[m] % 10 );
  	 n[m] = n[m] / 10;
  }
//printf("%d\n",n[m]);
	
printf("%d\n",reverse);

  }

return 0;
}

why m getting sigsegv

#include <stdio.h>
#include<stdlib.h>
int *intArray,n ;

void display(){
int i;
// navigate through all items
for(i = 0;i<n;i++){
printf("\n%d ",intArray[i]);
}
}

void swap(int num1, int num2){
int temp = intArray[num1];
intArray[num1] = intArray[num2];
intArray[num2] = temp;
}

int partition(int left, int right, int pivot){
int leftPointer = left -1;
int rightPointer = right;

while(1){

  while(intArray[++leftPointer] < pivot){
     //do nothing
  }
	
  while(rightPointer > 0 && intArray[--rightPointer] > pivot){
     //do nothing
  }

  if(leftPointer >= rightPointer){
     break;
  }else{
     swap(leftPointer,rightPointer);
  }

}
swap(leftPointer,right);
return leftPointer;
}

void quickSort(int left, int right){
if(right-left <= 0){
return;
}else {
int pivot = intArray[right];
int partitionPoint = partition(left, right, pivot);
quickSort(left,partitionPoint-1);
quickSort(partitionPoint+1,right);
}
}

int main(){
int i;
scanf("%d",&n);
intArray=(int*)calloc(n,sizeof(int));
for(i=0;i<n;i++)
scanf("%d",intArray[i]);
quickSort(0,n-1);
display();
free(intArray);
return 0;
}
questions:–
All submissions for this problem are available.

Given the list of numbers, you are to sort them in non decreasing order.
Input

t – the number of numbers in list, then t lines follow [t <= 10^6].
Each line contains one integer: N [0 <= N <= 10^6]

Output

Output given numbers in non decreasing order.
Example

Input:

5
5
3
6
7
1
Output:

1
3
5
6
7
why i am getting fragmentation error.?

why am i getting SIGEGV for this program https://www.codechef.com/viewsolution/11453342

whats wrong in this code. can some one help me out https://www.codechef.com/viewsolution/11554582

somebody please upvote me , i have questions to ask
thank you

This Error is related to Size of Array
The size of Array shall be ‘equal to or more than the no. of possible cases’.
eg: if there are 50 possible cases, maybe it’s not practical but your array size should be 50 or more.

At the same time, the Array size shall not be impractically large.
eg: A[1000000] will definitely give an Error.

Sometimes Dynamic Memory Allocation may also give this error.

plzz help y i m gtting SIGSEVG in this code https://www.codechef.com/viewsolution/11774988

Please help me. My code is giving a SIGSEGV and i am a noob. (LINK)