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
16
votes
3 answers

Python Segmentation fault: 11 on OSX

Im starting development with python, and tried some simple commands like calculations. But, some times python aborts with "Segmentation fault:11" In google i didnt find a similar issue or solution for that. Python is installed with…
Peter C. Glade
  • 543
  • 2
  • 8
  • 16
16
votes
4 answers

PyOpenCl: how to debug segmentation fault?

I have PyOpenCL code with OpenCL C kernel code. I catch segmentation fault error when I run my app. How to debug such error with some debugger or some other development tool? I don't know what exactly to do to find out the problem. I have in mind…
petRUShka
  • 9,812
  • 12
  • 61
  • 95
15
votes
6 answers

Best practices for recovering from a segmentation fault

I am working on a multithreaded process written in C++, and am considering modifying SIGSEGV handling using google-coredumper to keep the process alive when a segmentation fault occurs. However, this use of google-coredumper seems ripe with…
Sam
  • 307
  • 1
  • 2
  • 9
15
votes
4 answers

Python3 Relink issue while importing opencv

Question: I have a segmentation fault after trying to import a freshly compiled version of the latest available OpenCV from github on Ubuntu 18.04. Here is the error message I got while trying to import cv2 in Python 3: $ python3 Python 3.6.8…
swiss_knight
  • 5,787
  • 8
  • 50
  • 92
15
votes
1 answer

What happens when code that throws exceptions is linked against a library compiled with -fno-exceptions?

Specifically I'd like to know what, if any, guarantees are made by GCC about how code that throws exceptions behaves when linked against code compiled using -fno-exceptions. The GNU libstdc++ manual says the following here. Before detailing the…
Sam Marinelli
  • 999
  • 1
  • 6
  • 16
15
votes
9 answers

Rails segmentation fault when starting server?

Trying to get my rails 3 environment up and running and I keep encountering an error I can't get around. Any help would be great appreciated! Here is the problem: Patrick-Scotts-MacBook-Pro:~ PJS$ cd hope_app Patrick-Scotts-MacBook-Pro:hope_app PJS$…
Patrick
  • 151
  • 1
  • 1
  • 3
15
votes
1 answer

Java fatal error SIGSEGV with no added native code

I am getting an error message from the Java compiler that I don't understand. I've tested my code on OSX 10.6, 10.9, and Ubuntu 14.04, with both Java 6 and 7. When I run with the Eclipse debugger or from the interpreter (using -Xint option),…
jackkamm
  • 541
  • 1
  • 4
  • 11
15
votes
3 answers

Segmentation Fault With Char Array and Pointer in C on Linux

So I have the following program: int main(){ char* one = "computer"; char two[] = "another"; two[1]='b'; one[1]='b'; return 0; } It segfaults on the line "one[1]='b'" which makes sense because the memory that the pointer "one" points to…
ccoder
  • 153
  • 1
  • 4
15
votes
3 answers

Linux: handling a segmentation fault and getting a core dump

When my application crashes with a segmentation fault I'd like to get a core dump from the system. I do that by configuring before hand ulimit -c unlimited I would also like to have an indication in my application logs that a segmentation fault has…
shoosh
  • 76,898
  • 55
  • 205
  • 325
15
votes
2 answers

What error code does a process that segfaults return?

What error code does a process that segfaults return? From my experiments, it seems to be "139", but I'd like to find why this is so and how standard it is.
static_rtti
  • 53,760
  • 47
  • 136
  • 192
15
votes
3 answers

C++ Segmentation Fault when using cout in static variable initialization

I have a program where I use cout to emit debug information. The code is executed in the initialization of a static global variable, i.e. quite early in the program execution. When I use my own build script to build the program, it segfaults at the…
gexicide
  • 38,535
  • 21
  • 92
  • 152
15
votes
1 answer

Matlab segmentation fault when iterating vector assignment

I've been vectorizing some matlab code I'd previously written, and during this process matlab started crashing due to segmentation faults. I narrowed the problem down to a single type of computation: assigning to multiple struct properties. For…
zergylord
  • 4,368
  • 5
  • 38
  • 60
15
votes
3 answers

How to understand and solve crash report: SIGSEGV, SEGV_ACCERR

I am getting sometimes this crash report: Name: SIGSEGV Reason: SEGV_ACCERR Stack Trace: 0 MyApp 0x00070456 0x1000 + 455766 1 MyApp 0x0007a34d 0x1000 + 496461 2 MyApp 0x0007a4f1 0x1000 + 496881 3 MyApp 0x000d31dd 0x1000 + 860637 4 MyApp…
brush51
  • 5,691
  • 6
  • 39
  • 73
15
votes
4 answers

Is there any hard-wired limit on recursion depth in C

The program under discussion attempts to compute sum-of-first-n-natural-numbers using recursion. I know this can be done using a simple formula n*(n+1)/2 but the idea here is to use recursion. The program is as follows: #include unsigned…
Sangeeth Saravanaraj
  • 16,027
  • 21
  • 69
  • 98
14
votes
5 answers

Sprintf Segmentation Fault

numCheck is number between 1-1000. This code gives me a segfault only when I collect the results of sprintf in charcheck. If I simply use sprintf without using the results, I don't get a seg fault. What's happening here? char * numString; int…
syl
  • 247
  • 1
  • 4
  • 8