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

"segmentation fault" when assigning values to a specific position in a dynamically allocated matrix

I did this plenty of times but suddenly I can't get over this error. I've got a simple input.txt file with this structure: 3 4 2 1 1 1 2 3 8 3 3 Where the first line is basically the matrix's size and then follows value row col each line. I'm using…
2
votes
0 answers

Assembly Code Behaves Funny / Unexpected - ASM x86-64 Bit (AT&T, GAS)

My setup OS: ------------------ Linux Architecture: ------ x86-64 Syntax: ------------ AT&T Compiler: --------- GAS My code (explanation below) .section .text .globl _start print: movq $1, %rax movq $1, %rdi movq %rsp, %rsi popq %rbx …
Pixelbog
  • 236
  • 1
  • 8
2
votes
0 answers

Is there a way to ignore segfaults on exit of R processes?

In some R processes, I occasionally see the following on process exit: *** caught segfault *** address 0x80, cause 'memory not mapped' Traceback: 1: x$unload() 2: (function(x) x$unload())() An irrecoverable exception occurred. R is…
2
votes
1 answer

How to build Catboost C Evaluation Library API?

I had to use a Catboost model in some programming languages, Golang and Python. The best option (for performance and compatibility) is to use an evaluation library which can be a C or C++ API. I followed the official documentation to compile the C…
2
votes
0 answers

Using an external DLL in a Qt Project

I have a DLL containing multiple functions that can fastly perform arithmetic operations on extremely large integers. My test program runs smoothly in my Visual Studio 2019, as follows. int main() { HINSTANCE myDDL =…
2
votes
1 answer

C++ OpenGL Segmentation fault (core dumped) runtime error

When I tried to run this I got a "Segmentation fault (core dumped) error and nothing ran: #include #include #include #include #include #include…
2
votes
2 answers

Why am I getting a segmentation fault (core dumped) from scanf?

I'm writing a program where we have to just ask the user for a movie title, adult tickets sold, and child tickets sold and then it displays calculated information based on what was entered. I'm getting a Segmentation fault (core dumped) error very…
birchwoody
  • 39
  • 4
2
votes
1 answer

Arrays in Objective-C main method. Sigserve errors. Newb

In Objective-C how should I best approximate what in Java I am doing like this: static private String[] array {"A", "B", "C"}; What I think I need is a simple array that I can index into with some integers. Alternative suggestions are welcome but…
pie
  • 33
  • 1
  • 1
  • 4
2
votes
2 answers

gdb always returns segmentation fault

I'm trying to use gdb (Ubuntu 12.1) on my Ubuntu VM (22.04.1 LTS), but whenever I try the run command it always gives a segmentation fault, regardless of the program being debugged. (gdb) run Starting program: /home/dir/a.out Program received…
LeoPipo
  • 21
  • 2
2
votes
3 answers

My code crashes on delete this

I get a segmentation fault when attempting to delete this. I know what you think about delete this, but it has been left over by my predecessor. I am aware of some precautions I should take, which have been validated and taken care of. I don't get…
Eric
  • 19,525
  • 19
  • 84
  • 147
2
votes
3 answers

signal 11 (SIGSEGV)

I wrote the following code: FILE *book; wchar_t bufferln[FILE_READ_BUFFER]; wchar_t buffer[FILE_READ_BUFFER]; book = fopen(file, "r"); if(book == NULL){ perror("Es ist ein Fehler beim lesen des Buches aufgetreten"); return…
Jonas Osburg
  • 1,733
  • 1
  • 14
  • 17
2
votes
2 answers

GCP Cloud Run container fails with Uncaught signal: 11 Segmentation fault - Node - Fastify

I have a node server application using Fastify. I can build and run the image locally without a trouble. But when I deploy to the cloud, it fails to start and gives Uncaught signal: 11 - Segmentation fault. After doing some digging I found that it's…
2
votes
1 answer

C Program bump into segmentation fault. (gdb) Cannot access memory at address

I am trying to write codes in C for dynamic array (vector), and it runs okay until I add another function pointer into the struct (line29: int (findEle)(vector, int) ), and initialize it (line 153: v->findEle = findEle) to point to the function…
k.cc
  • 23
  • 2
2
votes
0 answers

How to resolve "Too many open files: " error?

I'm trying to list all the subdirectories of a specific path something like this rootdir = 'build/system/' def list_dirs(rootdir): for dir in os.scandir(rootdir): if not os.listdir(rootdir): sys.exit("Directory is empty") …
2
votes
3 answers

Unclear segmentation fault in a constructor

I have built a constructor for a matrix object. The data is being stored in an array of struct val, which in turn hold position (in the matrix) and value. This is the code: SparseMatrix::SparseMatrix(const int numRow, const int numCol,…
yotamoo
  • 5,334
  • 13
  • 49
  • 61
1 2 3
99
100