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
13
votes
7 answers

PyCharm debug segmentation fault (signal 11)

In PyCharm (community edition 2016.2.3), using anaconda2 + ubuntu 14.04, import matplotlib causes a signal 11 error during the debug mode. There is no problem when executing the script in release mode. The python code: import matplotlib as pt The…
user155322
  • 717
  • 3
  • 8
  • 17
13
votes
1 answer

A lot of SIGSEGV while strace'ing java process

Interesting stuff occurred while I debug one of the unit tests on CI server (maven build actually). I connect to java process with strace -ff -e trace=network -p [pid] to trace network activity of build process. And that's what I saw: Process 26324…
Denis Bazhenov
  • 9,680
  • 8
  • 43
  • 65
13
votes
3 answers

Best way on how to solve/debug JVM crash (SIGSEGV)

I'm really lost and I don't know how to face and solve my problem. I have a piece of simple Java Code, which leads to a JVM crash: # # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00000001057ce9d4,…
Philipp
  • 1,289
  • 1
  • 16
  • 37
13
votes
1 answer

When using a coredump in gdb how do I know exactly which thread caused SIGSEGV?

My application uses more than 8 threads. When I run info threads in gdb I see the threads and the last function they were executing. It does not seem obvious to me exactly which thread caused the SIGSEGV. Is it possible to tell it? Is it thread 1?…
russoue
  • 5,180
  • 5
  • 27
  • 29
13
votes
3 answers

Zsh menu completion causes problems after zle reset-prompt

I have following code in my .zshrc: TMOUT=1 TRAPALRM() { zle reset-prompt } After triggering menu completion all items from menu, except highlighted one disappear after TRAPALRM triggers and when i keep navigating in menu zsh segvaults after a…
Ryba
  • 681
  • 4
  • 13
13
votes
2 answers

Android Fatal Signal 7 (SIGBUS)

I'm getting a few SIGBUS (7) and SIGSEGV (11) crashes that I am having difficult tracking down. The thread that appears to be causing the crash is primarily used for loading images to be displayed which makes sense since the logs indicate something…
Nyx
  • 2,233
  • 1
  • 12
  • 25
13
votes
2 answers

Malloc segmentation fault

Here is the piece of code in which segmentation fault occurs (the perror is not being called): job = malloc(sizeof(task_t)); if(job == NULL) perror("malloc"); To be more precise, gdb says that the segfault happens inside a __int_malloc call,…
13
votes
4 answers

Is the main thread allowed to spawn a POSIX thread before it enters main()?

I have this object that contains a thread. I want the fate of the object and the fate of the thread to be one in the same. So the constructor creates a thread (with pthread_create) and the destructor performs actions to cause the thread to return in…
Mike
  • 400
  • 2
  • 10
13
votes
1 answer

C++11 std::vector in concurrent environment

I had an issue (segfault) running a multithreaded code in C++11. Here it is the code: #include #include std::vector values; int i; void values_push_back() { values.push_back(i); } int main() { while(true) { …
12
votes
2 answers

segfault using numpy's lapack_lite with multiprocessing on osx, not linux

The following test code segfaults for me on OSX 10.7.3, but not other machines: from __future__ import print_function import numpy as np import multiprocessing as mp import scipy.linalg def f(a): print("about to call") ### these all cause…
Danica
  • 28,423
  • 6
  • 90
  • 122
12
votes
2 answers

Why do system calls return EFAULT instead of sending a segfault?

To be clear, this is a design rather than an implementation question I want to know the rationale behind why POSIX behaves this way. POSIX system calls when given an invalid memory location return EFAULT rather than crashing the userspace program…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
12
votes
6 answers

Segfault on stack overflow

Why does the linux kernel generate a segfault on stack overflow? This can make debugging very awkward when alloca in c or fortran creation of temporary arrays overflows. Surely it mjust be possible for the runtime to produce a more helpful error.
Jim McElwaine
12
votes
4 answers

When a JVM crashes (segfaults) during garbage collection, how can I find out what was being collected?

I get segfaults in my JVM at roughly the same phase of the application, but with varying stack traces in the crash report. It always seems to happen during GC, however. Since the crash happens in all three JVMs I tried (OpenJDK 6, Oracle 1.6.0_25…
12
votes
3 answers

Access Base class variable from child class method

How can I access base class variable from a child method? I'm getting a segmentation fault. class Base { public: Base(); int a; }; class Child : public Base { public: void foo(); }; …
Mattia
  • 173
  • 1
  • 1
  • 7
12
votes
1 answer

Possible undefined behavior in primitive static_vector implementation

tl;dr: I think my static_vector has undefined behavior, but I can't find it. This problem is on Microsoft Visual C++ 17. I have this simple and unfinished static_vector implementation, i.e. a vector with a fixed capacity that can be stack allocated.…
pjohansson
  • 17,796
  • 3
  • 17
  • 18