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

C++ Access to vector from multiple threads

In my program I've some threads running. Each thread gets a pointer to some object (in my program - vector). And each thread modifies the vector. And sometimes my program fails with a segm-fault. I thought it occurred because thread A begins doing…
Kolyunya
  • 5,973
  • 7
  • 46
  • 81
11
votes
6 answers

Determine static initialization order after compilation?

In C++, I know that the compiler can choose to initialize static objects in any order that it chooses (subject to a few constraints), and that in general you cannot choose or determine the static initialization order. However, once a program has…
Tyler McHenry
  • 74,820
  • 18
  • 121
  • 166
11
votes
4 answers

Easiest way to locate a Segmentation Fault

I encountered my first Segmentation Fault today (newbie programmer). After reading up on what a segmentation fault is (Thanks for all of the helpful info on this site, as well as Wikipedia's lengthy explanation), I'm trying to determine the easiest…
TZPike05
  • 1,188
  • 5
  • 15
  • 24
11
votes
1 answer

gdb: Program exited with code 030000000375

I am teaching myself to use gdb and am running some random tests. It may be worth mentioning that I am using a portable installation of MinGW on Windows 7 x64. I've created a program which I know results in a stack overflow, and as I run through…
The111
  • 5,757
  • 4
  • 39
  • 55
11
votes
1 answer

glGenBuffers() crashing with Segmentation fault. (C++/GLFW/GLEW)

So, in my project I am using a seperate class to create buffers called Buffer.cpp. Here is the constructor #define GLEW_STATIC #define GLEW_NO_GLU #define GLFW_NO_GLU #include "GL/glew.h" #include "GL/glfw.h" Buffer::Buffer(GLenum _type, const…
Andreas Goulas
  • 163
  • 1
  • 1
  • 11
11
votes
2 answers

Linux: How to debug a SIGSEGV? How do I trace the error source?

My firefox started crashing since today. I haven't changed anything on the system or on firefox config. I use strace -ff -o dumpfile.txt firefox to trace the problem. It's not a big help. I see the segfault, in two of the generated process…
ivan_ivanovich_ivanoff
  • 19,113
  • 27
  • 81
  • 100
10
votes
2 answers

Why does my application crash sometimes with a SIGSEGV when it gets closed?

I have written an application in c++ which uses Qt 4.7.4. When starting up, it loads some selfwritten dynamic libraries which also use Qt (if this could be useful in a way). When closing the application, sometimes it crashes with a SIGSEGV and the…
Sämy
  • 799
  • 2
  • 7
  • 17
10
votes
3 answers

SIGSEGV in optimized version of code

My knowledge of the intel instruction set is a bit rusty. Can you tell me why I might be getting a segmentation fault in the optimized version of my function (bonus points if you can tell me why I don't get it in the -O0 build of the code. It's C…
laslowh
  • 8,482
  • 5
  • 34
  • 45
10
votes
1 answer

Can anyone explain what IOT instruction (core dumped) refers to?

I’m getting the following problem when executing a C program: ~$ ./a.out zsh IOT instruction (core dumped) ./a.out I’ve never seen this before, and I don’t know how to solve it. What is it? Please not that I’m not looking for a solve to this…
R-Rothrock
  • 303
  • 2
  • 14
10
votes
5 answers

easiest way to debug crash in native library, linked by Android app?

I have ported and created several low-level C-libraries to Android for my use in my application. I cross-compiled them using the NDK, and then link to them using System.loadLibrary(). After some amount of time, my application crashes, seemingly…
gnychis
  • 7,289
  • 18
  • 75
  • 113
10
votes
4 answers

How to fix "Segmentation fault (core dumped)" when creating new dotnet project?

I am following https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/create When I try to create a project, I get the following: oskar@oskarslaptop:~/Programming/Resorvoir-CLI$ dotnet new console -o MyApp Segmentation fault (core dumped) I…
OskarZyg
  • 135
  • 1
  • 2
  • 10
10
votes
5 answers

Catch Segfault or any other errors/exceptions/signals in C++ like catching exceptions in Java

I wrote a Linux program based on a buggy open source library. This library sometimes triggers segfaults that I cannot control. And of course once the library has segfaults, the entire program dies. However, I have to make sure my program keeps…
CuriousMind
  • 15,168
  • 20
  • 82
  • 120
10
votes
1 answer

libc's system() when the stack pointer is not 16-padded causes segmentation fault

I've noticed a really weird behavior when I was playing with libc's system() function on x86-64 linux, sometimes the call to system() fails with a segmentation fault, here's what I got after debugging it with gdb. I've noticed that the segmentation…
shaqed
  • 342
  • 3
  • 17
10
votes
4 answers

Calling isalpha Causing Segmentation Fault

I have the following program that causes a segmentation fault. #include #include #include int main(int argc, char *argv[]) { printf("TEST"); for (int k=0; k<(strlen(argv[1])); k++) { if…
10
votes
7 answers

Segmentation fault (core dumped) on tf.Session()

I am new with TensorFlow. I just installed TensorFlow and to test the installation, I tried the following code and as soon as I initiate the TF Session, I am getting the Segmentation fault (core dumped) error. bafhf@remote-server:~$ python Python…
Benison Sam
  • 2,755
  • 7
  • 30
  • 40