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

Error: SIGSEGV when running application on Mono

After hours of trying to get this to work, I have decided it's time to post. I have a C# Windows Forms application that is quite basic, and I can complie and run it fine on windows. The whole project is designed to work on a Pi though, so I moved…
Wayneio
  • 3,466
  • 7
  • 42
  • 73
3
votes
1 answer

memory management and segmentation faults in modern day systems (Linux)

In modern-day operating systems, memory is available as an abstracted resource. A process is exposed to a virtual address space (which is independent from address space of all other processes) and a whole mechanism exists for mapping any virtual…
3
votes
1 answer

Why is this wrong!? Generating strings

I've been trying to generate strings in this way: a b . . z aa ab . . zz . . . . zzzz And I want to know why Segmentation fault (core dumped) error is prompted when it reaches 'yz'. I know my code don't cover all the posibles strings like 'zb' or…
3
votes
3 answers

Problems with double pointers

I'm getting a segmentation fault when I try to create a new Node object with the pointer variable *temp in line 15 below. I'm still pretty new to c++ and how double pointers work, especially when used in combination with &. Thanks for any help. void…
midma101
  • 139
  • 1
  • 11
3
votes
1 answer

Debugging a segfault in Perl

I'm trying to debug a segfault I'm getting from Perl. I'm using: Perl 5.8.8 Net::SSH2 0.45 Libssh2 1.4.2 Openssl 0.9.8x (but I've also have the same problem with 1.0.1c) The problem happens when I call: my $ssh = Net::SSH2->new(); I've run it…
bahamat
  • 738
  • 2
  • 9
  • 19
3
votes
2 answers

Why am I getting a segmentation fault (qtruby)?

I've been having an issue with segmentation faults when accessing a class variable (an array of Qt::Actions), and I've been trying to whittle it down to a minimal code example that replicates the issue: #!/usr/bin/ruby require 'Qt4' require…
Vala
  • 5,628
  • 1
  • 29
  • 55
3
votes
4 answers

C++ Segmentation Fault in vector serialize/deserialize

Please help me debug the below code. What I am doing is just serialize vector into binary file and retrieving it back from it. Here is the example main code, /* Portion Commented */ vector
Prabu
  • 1,225
  • 4
  • 18
  • 26
3
votes
1 answer

Huffman Code - Segmentation Fault 11

Ok I have tried to make the Hauffman Code by my own and I have a problem when I'm trying to print the corresponding code to each letter with a recursive method. (By this point I already created a BinaryTree and root is not NULL) Each node has a…
3
votes
2 answers

Realloc an int array

I'm trying to create an array to hold an int, then when another int is to be added increase it in size to hold another int.. and so on.. I know it's not an efficient use of realloc, but it's proof on concept more than anything else. Just to get it…
Draconian Times
  • 319
  • 1
  • 3
  • 12
3
votes
5 answers

Trying to use execvp() in C with user input in unix

I'm trying to make a program that will prompt the user for a command, then use exec to execute that command. For instance if they gave me "ls -la" I would have to execute that command. I've tried the following code: #include #include…
Nick
3
votes
2 answers

C++ segmentation error when first parameter is null in comparison operator overload

I am writing a class called Word, that handles a c string and overloads the <, >, <=, >= operators. word.h: friend bool operator<(const Word &a, const Word &b); word.cc: bool operator<(const Word &a, const Word &b) { if(a == NULL && b == NULL) …
fvf
  • 27
  • 7
3
votes
1 answer

How to follow fatal signal 11 (SIGSEGV)

I'm developing an android app, with opencv and tesseract for OCR. I used a little of code from basic OCR of guat.am, Bitmap bmp = Bitmap.createBitmap(ima.cols(), ima.rows(), Bitmap.Config.ARGB_8888); Utils.matToBitmap(imagethre,…
fabrigm
  • 648
  • 1
  • 6
  • 14
3
votes
3 answers

Very simple program in fortran giving me a segmentation fault. Very confused

I've been going crazy trying to read in some data into arrays in my simple program. I cannot work out why I am getting a segmentation fault. My code begins: program guess_input implicit none CHARACTER*2, allocatable, dimension(:) :: element double…
3
votes
0 answers

Crash in CoreData in -[NSManagedObjectContext save:]

A note, I've already checked the following posts:(Stack overflow issue 1 Stack overflow issue 2 I am seeing the following crash stack in my app: 2 libsystem_c.dylib 0x32bc87ec _sigtramp + 48 3 CoreData 0x361a2e70 -[NSSQLCore…
Dru Freeman
  • 1,766
  • 3
  • 19
  • 41
3
votes
1 answer

Segmentation Fault in Zend Framework2 trying to add to sqlite db

I am currently trying to get around with the Zend Framework 2 Tutorial. I am using an Apache 2 and php 5.4.7 with Zend Engine v2.4.0 on a Solaris system. I managed to create everything I need but when I want to add or delete an album from my list…