# Why do I get a SIGSEGV?

**URL:** <https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773>\
**Category:** faq\
**Tags:** faq, rte, sigsegv\
**Created:** [March 20, 2013, 5:03pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773 "2013-03-20T17:03:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rudreshwar](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@rudreshwar](https://discuss.codechef.com/u/rudreshwar)\
**Post date:** [March 20, 2013, 5:03pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/1 "2013-03-20T17:03:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![admin](https://discuss.codechef.com/user_avatar/discuss.codechef.com/admin/32/212587_2.png) [@admin](https://discuss.codechef.com/u/admin)\
**Post date:** [March 20, 2013, 5:05pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/2 "2013-03-20T17:05:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thepranay14](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@thepranay14](https://discuss.codechef.com/u/thepranay14)\
**Post date:** [November 7, 2014, 5:01pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/3 "2014-11-07T17:01:53Z")

</div>

//why i was getting SIGSEGV??  
//for this question [CodeChef: Practical coding for everyone](http://www.codechef.com/COQU2014/problems/DCQ1402)  
//please help n explain

for this solution [CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/5277974)

---

<div class="post-metadata">

**Author:** ![gokul95](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@gokul95](https://discuss.codechef.com/u/gokul95)\
**Post date:** [November 25, 2014, 8:07pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/4 "2014-11-25T20:07:39Z")

</div>

why do i get SIGSEV for the problem [CodeChef: Practical coding for everyone](http://www.codechef.com/KAN14ROL/problems/ACM14KN3/)

---

<div class="post-metadata">

**Author:** ![gokul95](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@gokul95](https://discuss.codechef.com/u/gokul95)\
**Post date:** [November 25, 2014, 8:08pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/5 "2014-11-25T20:08:14Z")

</div>

solution is [CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/5456719)

---

<div class="post-metadata">

**Author:** ![rishikeshfanse](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@rishikeshfanse](https://discuss.codechef.com/u/rishikeshfanse)\
**Post date:** [December 15, 2014, 4:13pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/6 "2014-12-15T16:13:32Z")

</div>

why am i getting sigsev for the solution at [CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/5601458)

---

<div class="post-metadata">

**Author:** ![visght](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@visght](https://discuss.codechef.com/u/visght)\
**Post date:** [January 19, 2015, 11:20pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/7 "2015-01-19T23:20:40Z")

</div>

can anyone help m why m getting SIGSEGV RUNTIME ERROR [CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/5940071)

---

<div class="post-metadata">

**Author:** ![vineeta1995](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@vineeta1995](https://discuss.codechef.com/u/vineeta1995)\
**Post date:** [January 22, 2015, 10:06am UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/8 "2015-01-22T10:06:19Z")

</div>

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);  
}

---

<div class="post-metadata">

**Author:** ![anmolnijhawan](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@anmolnijhawan](https://discuss.codechef.com/u/anmolnijhawan)\
**Post date:** [January 25, 2015, 12:57pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/9 "2015-01-25T12:57:37Z")

</div>

please help why do i get sigsegv in this code [CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/5988352)

---

<div class="post-metadata">

**Author:** ![nikkey](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@nikkey](https://discuss.codechef.com/u/nikkey)\
**Post date:** [February 4, 2015, 12:31pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/10 "2015-02-04T12:31:39Z")

</div>

why do i get SIGSEVG

---

<div class="post-metadata">

**Author:** ![riapant2014](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@riapant2014](https://discuss.codechef.com/u/riapant2014)\
**Post date:** [February 7, 2015, 11:09pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/11 "2015-02-07T23:09:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![prek](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@prek](https://discuss.codechef.com/u/prek)\
**Post date:** [February 8, 2015, 12:53pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/12 "2015-02-08T12:53:53Z")

</div>

why am i getting SIGEVG?[CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/6153699)  
please help

---

<div class="post-metadata">

**Author:** ![ashubaba](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@ashubaba](https://discuss.codechef.com/u/ashubaba)\
**Post date:** [February 8, 2015, 4:03pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/13 "2015-02-08T16:03:07Z")

</div>

can anyone help me…why i am getting SIGSEVG error in this [PeQwg9 - Online C Compiler & Debugging Tool - Ideone.com](http://ideone.com/PeQwg9)  
thanks in advance

---

<div class="post-metadata">

**Author:** ![ashubaba](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@ashubaba](https://discuss.codechef.com/u/ashubaba)\
**Post date:** [February 8, 2015, 4:03pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/14 "2015-02-08T16:03:29Z")

</div>

can anyone help me…why i am getting SIGSEVG error in this [PeQwg9 - Online C Compiler & Debugging Tool - Ideone.com](http://ideone.com/PeQwg9)  
thanks in advance

---

<div class="post-metadata">

**Author:** ![vandana\_95](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@vandana\_95](https://discuss.codechef.com/u/vandana_95)\
**Post date:** [February 25, 2015, 9:03pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/15 "2015-02-25T21:03:05Z")

</div>

#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]);

```

}

---

<div class="post-metadata">

**Author:** ![deepak100](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@deepak100](https://discuss.codechef.com/u/deepak100)\
**Post date:** [March 1, 2015, 12:03am UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/16 "2015-03-01T00:03:07Z")

</div>

why am i getting SIGSEVG ? [CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/6368752) plzzzzz help me!! Thank U…

---

<div class="post-metadata">

**Author:** ![sharru05](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@sharru05](https://discuss.codechef.com/u/sharru05)\
**Post date:** [March 1, 2015, 12:47am UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/17 "2015-03-01T00:47:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jobsiit](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@jobsiit](https://discuss.codechef.com/u/jobsiit)\
**Post date:** [March 1, 2015, 1:49pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/18 "2015-03-01T13:49:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jobsiit](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@jobsiit](https://discuss.codechef.com/u/jobsiit)\
**Post date:** [March 1, 2015, 2:00pm UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/19 "2015-03-01T14:00:51Z")

</div>

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](http://jobsiit.com/jobs/view/1876/Adobe-Systems/Software-Engineer)**

---

<div class="post-metadata">

**Author:** ![rjrakshit](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@rjrakshit](https://discuss.codechef.com/u/rjrakshit)\
**Post date:** [March 3, 2015, 1:36am UTC](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773/20 "2015-03-03T01:36:44Z")

</div>

Why do I get SIGSEGV error for this code [CodeChef: Practical coding for everyone](http://www.codechef.com/viewsolution/6382701)

[Next page](https://discuss.codechef.com/t/why-do-i-get-a-sigsegv/1773.md?page=2)
