Questions tagged [segmentation-fault]

Segmentation faults occur when accessing memory which does not belong to your process. Use this tag along with a tag indicating the language and a tag indicating the operating system. Segmentation faults are typically the result of a dereference operation with pointer variables (most often containing an invalid address) or a buffer overflow. The root cause for an invalid pointer value may be far from the location generating the segmentation fault.

Segmentation faults occur when accessing memory which does not belong to your process. They are common and typically the result of:

  • using a pointer to something that has been deallocated;
  • using an uninitialized hence bogus pointer;
  • using a pointer;
  • overflowing a buffer; or
  • attempting to write to read-only memory

The error does not arise when manipulating the pointer variable itself (copying or assigning the pointer variable), but when accessing the memory the variable points to (i.e. dereferencing the pointer variable). To generate the segmentation fault, will deliver 11 to the process which has made illegal memory access. The default action of having segmentation fault is , generating a coredump file with basic process information.

Since the point where the segmentation fault is triggered may be far from the location where the environment and actions that generate the conditions for the segmentation fault, finding the root cause can be difficult, especially in a complex, multi-threaded application.

Segmentation fault is descriptive phrase from Unix and Linux families of operating systems labeling a general class of behavior in which the operating system detects a memory access by a process outside of the process' assigned memory resulting in the operating system terminating the process.

This behavior requires hardware support for protected memory which may not be available in some microprocessors.

Additional information can be found on...

If the program crashed due to

  1. unauthorized memory access
  2. using out-of-bound memory location
  3. using of uninitialized memory

and it has received SIGSEGV and/or a coredump file is getting generated, mark your questions using this tag.

13352 questions
27
votes
3 answers

What can cause a Java native function (in C) to segfault upon entry?

The Project I'm writing a Java command line interface to a C library of internal networking and network testing tools using the Java Native Interface. The C code (which I didn't write) is complex and low level, often manipulates memory at the bit…
Griff George
  • 895
  • 7
  • 17
26
votes
1 answer

EXC_BAD_ACCESS (SIGSEGV) in WebCore::UserGestureIndicator::processingUserGesture

I have an iOS application built using a UIWebView and HTML5 websockets. The app experiences seemingly random crashes. It has occurred while a user is interacting with it and during longevity tests where no interaction between user and app…
user320487
26
votes
7 answers

Signal 11 SIGSEGV Crash in Galaxy S3 Android WebView

I have a complex, interactive HTML5 in an Android WebView - and it works fine on basically all platforms except Galaxy S3. On Galaxy S3 (Android 4.0.4), once out of every 5 times or so, just after the load completes, /system/lib/libwebcore.so tries…
John Abrehamson
  • 261
  • 1
  • 3
  • 5
25
votes
1 answer

gcc-10.0.1 Specific Segfault

I have an R package with C compiled code that's been relatively stable for quite a while and is frequently tested against a broad variety of platforms and compilers (windows/osx/debian/fedora gcc/clang). More recently a new platform was added to…
BrodieG
  • 51,669
  • 9
  • 93
  • 146
25
votes
1 answer

How to figure out the reason of a SIGSEGV in Android

I've been getting increasing number of reports that my android app crashes, the crash happens in native code so a stacktrace isn't produced. I have only one native function and it isn't the problem because it's called once during startup and the…
Danny
  • 473
  • 2
  • 5
  • 11
24
votes
10 answers

Crashes normally, but not with GDB

My program crashes with a segmentation fault when ran normally. So I run it with GDB, but it won't crash when I do that. Why might this occur? I know that Valgrind's FAQ mentions this (not crashing under Valgrind), but I couldn't really find…
Sterling
  • 3,835
  • 14
  • 48
  • 73
24
votes
10 answers

Why can't I cause a seg fault?

OK for whatever reason I'm having trouble causing a seg fault. I want to produce one so that I can use gdb to see how to debug one. I have tried both examples from the Wikipedia article yet neither work. The first one: char *s = "Hello World!"; *s =…
Bob Dylan
  • 4,393
  • 9
  • 40
  • 58
24
votes
2 answers

Counter exit code 139 when running, but gdb make it through

My question sounds specific, but I doubt it still can be of a C++ debug issue. I am using omnet++ which is to simulate wireless network. omnet++ itself is a c++ program. I encountered a queer phenomena when I run my program (modified inet framework…
ulyssis2
  • 1,165
  • 3
  • 10
  • 24
23
votes
4 answers

is boost::property_tree::ptree thread safe?

I'm using boosts read_json in a couple of threads in a piece of code. A simplified breakdown of the call is below. I'm getting segfaults in one of the threads (and sometimes the other) and it's making me think that read_json is not thread safe (Or…
Ross W
  • 1,300
  • 3
  • 14
  • 24
23
votes
5 answers

Pointer-array-extern question

File 1.c int a[10]; File main.c: extern int *a; int main() { printf("%d\n", a[0]); return 0; } Gives me a segfault! What's going wrong?
Rajendra Uppal
  • 19,218
  • 15
  • 59
  • 57
23
votes
1 answer

OSX, ghci, dylib, what is the correct way?

I need to build some C code and then reference that C code via the FFI. I would like to use my binding from inside ghci on osx. On of my constraints is that I cannot just hand the C sources to ghc in the .cabal file. This is due to a limitation…
Jason Dagit
  • 13,684
  • 8
  • 33
  • 56
23
votes
2 answers

SIGNAL 11 SIGSEGV crash Android

Today I faced an error due to which my Android application is getting by SIGNAL 11. This error usually occurs due to unauthorized memory area access by Android internal storage. Some of the possible scenarios are web access, network communication,…
Rohit Mandiwal
  • 10,258
  • 5
  • 70
  • 83
23
votes
4 answers

Segmentation Fault before main

so I've been running into a problem where somehow my code is causing segmentation faults before any of my main actually runs. I've never had this happen before and I hardly have a quarter's worth of coding experience so I'm not sure if there's…
aperson231
  • 241
  • 1
  • 2
  • 6
23
votes
1 answer

Why is there a length limit to python's eval?

I'm not advocating that this would ever be a good idea, but I've found that you can crash Python (2.7 and 3.2 checked) by running eval on a large enough input string: def kill_python(N): S = '+'.join((str(n) for n in xrange(N))) return…
Hooked
  • 84,485
  • 43
  • 192
  • 261
23
votes
3 answers

segmentation fault with strcpy

I am wondering why am I getting segmentation fault in the below code. int main(void) { char str[100]="My name is Vutukuri"; char *str_old,*str_new; str_old=str; strcpy(str_new,str_old); puts(str_new); …
Teja
  • 13,214
  • 36
  • 93
  • 155