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
2
votes
1 answer

Getting segmentation fault in a code of AVL tree

I have a code for AVL tree here: #include #include using namespace std; typedef struct avl { avl *left; avl* right; avl* parent; int data; } avl; class AVL{ avl* root; public: void insert(int…
2
votes
0 answers

pyttsx3/pyttsx4 give segmentation fault: 11

I'm trying to use the pyttsx3 module but it crashes the python env and gives me a segmentation fault as soon as I call the pyttsx3.init() method. Thought it might be an issue of pyttsx3 being outdated so I tried the same with pyttsx4 but no…
2
votes
1 answer

For loop segmentation fault

I am attempting to create a DVR simulation in C. I know that I need a nested for loop, but whenever I compile and run the program it produces a segmentation fault after entering the number of routers in the system. The compiler is not producing any…
2
votes
4 answers

Trouble tracking down a Bus Error/Seg Fault in C++ and Linux

I have a program that processes neural spike data that is broadcast in UDP packets on a local network. My current program has two threads a UI thread and a worker thread. The worker thread simply listens for data packets, parses them and makes them…
slayton
  • 20,123
  • 10
  • 60
  • 89
2
votes
3 answers

Why am I getting segmentation fault (core dumped) before any part of my main function runs

I am very new to C and I have written a relatively simple code for an assignment that is supposed to take input from a file byte by byte and print a table of the hex values for the file similarly to the -od command. I moved all the code to a single…
2
votes
1 answer

strcmp() Segmentation Fault in C

When I call this function, my code always breaks in the strcmp and returns a Segmentation Error with no more information provided. stop_t *getStop(char *name) { node_t *current = stop_list_head; stop_t *stop; while (current != NULL) { …
mcsmachado
  • 69
  • 6
2
votes
1 answer

uWSGI Segmentation Fault With Flask/Python App Behind Nginx After Running for ~24 hours

Problem I have a Python/Flask app running in prod with uWSGI behind Nginx that deploys my personal projects via Docker. It works great for about 12-24 hours when it suddenly starts segfaulting. The app accepts requests and starts a Python thread to…
Justin Hammond
  • 595
  • 8
  • 20
2
votes
0 answers

Android Emulator segmentation fault (core dumped) on Ubuntu 20.04

I downloaded the AOSP 13 code (r24 tag) from Google. I gave the launch option as launch sdk_phone_x86_64, and then compiled the code. After compiling, I ran emulator command, I am getting a segmentation fault with core dumped error. Below is the…
2
votes
2 answers

Are there any issues from both the child and parent destructors being called when a derived object is destroyed?

If I have the below two classes: #include class Parent { protected: int* mem = (int*) std::malloc(5); // pointer to dynamically-stored object public: Parent() {}; virtual ~Parent() { …
2
votes
0 answers

internal compiler error: Segmentation fault with gcc 7

I am facing Segmentation fault issue during source code compilation. I came across few other forums here where upgrading gcc version would help. But i am already in later version than the one mentioned in above forum. Log: x86_64-pc-linux-gnu-g++:…
Kiran
  • 75
  • 7
2
votes
3 answers

strncpy segfault

I've been having trouble getting this section of code to work. I'm trying to get a character array to be copied so I can get a count of how many tokens there are to dynamically allocate and save them to be examined for environment variables.…
GFXGunblade
  • 97
  • 3
  • 10
2
votes
0 answers

Why does GCC make my program crash, but as & ld do well?

My environment: OS: Linux 4.15.0-202-generic Ubuntu SMP x86_64 GCC: gcc (Ubuntu 4.8.5-4ubuntu8) 4.8.5 I wrote a simple assembly program, named 'helloworld.s': .section .data msg: .asciz "Hello world!\n" .section .text .globl _start _start: …
zhouz
  • 29
  • 1
2
votes
0 answers

C++ sort algorithm segmentation fault

Why will this code cause segmentation fault with this input? If I change >= to > within the lambda function the segfault won't appear. My code is #include #include #include #include using namespace std; int…
2
votes
0 answers

Memory problems with a course exercise in C

I'm following a course about programming and went smooth so far. Now I'm stuck into this exercise which asks us to reverse a WAV file in C. I have two questions about it: It seems to work and correctly reverse few seconds audios but on longer ones…
NRevan
  • 21
  • 2
2
votes
0 answers

fluent-ffmpeg throwing SIGSEGV in nodejs

I am using fluent-ffmpeg to resize a video, split into frames, etc. Here's my code: ffmpeg("./uploads/video.mp4") .output("./uploads/small-video.mp4") .noAudio() .size('320x?') .on('end', function() { …
C G
  • 21
  • 2