What could be the possible reasons for segmentation fault?

Let’s learn what could be the possible reasons for segmentation fault. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

Possible reasons for segmentation fault on function exit

What possible reasons can you think of for a segmentation fault on exiting a function in C++? What I mean by that is, that I have a reproducible segmentation fault in a C++ program, and when I investigate using GDB is says Program received signal SIGSEGV, Segmentation fault. FooBar (bla=...) at foo.cpp:59 59 } where the indicated line contains the closing bracket of my function.

Answer:

There could be many reasons of this. Run program under Valgrind and most likely it will tell you exact...

Read more

dcn at Stack Overflow Mark as irrelevant Undo

Other solutions

Segmentation fault

QUESTION: Hi! I wrote this code and when i run i get a "Segmentation fault" and it doesn't tell me what line. Can you tell me where this problem is coming, from this code? I entered the value 9070002043 or 9995500000 for the input i get a segmentation...

Answer:

I can't see anything else obviously causing the problem. My guess would be that the data in the file...

Read more

Miningco.com Mark as irrelevant Undo

Why is a segmentation fault called a segmentation fault?

I understand that a segfault is an access violation to memory that the CPU cannot physically address, but why is it called a "segmentation" fault.

Answer:

That is old terminology from the days when memory management was done through many variable length segments...

Read more

George Gonzalez at Quora Mark as irrelevant Undo

Segmentation fault in home-grown C string manipulation code...

I am working on a string manipulation library in C. I am trying to create my own version of the strchr() function, using the following code: char *es_strchr(char needle, char * haystack) { int count_a = 0; int count_b = 0; int found_needle = 0; char...

Answer:

Zefyre, Your code has several problems. One of which is that it does not actually do what strchr()...

Read more

zefyre-ga at Google Answers Mark as irrelevant Undo

C++ Segmentation Fault?

This program is supposed to allow the user to enter 5 names and then add one, delete one, and try to delete one that's not on the list. I can add one, but keep getting "segmentation fault" after trying to delete one. Any suggestions? #include...

Answer:

The main problem I see is in both addEntry() and deleteEntry(). They both reallocate the array, but...

Read more

bethann_... at Yahoo! Answers Mark as irrelevant Undo

Segmentation fault with ccsm in ubuntu(linux)?

which opening compiz config setting manager(ccsm) via terminal it comes for a second and it vanishes,and says segmentation fault what should i do?

Answer:

You can try uninstalling and reinstalling Compiz. You can do this through System - Administration -...

Read more

Ritz at Yahoo! Answers Mark as irrelevant Undo

Segmentation fault Core Dumped. C program?

I have to write a program for my class and I am having a bit of trouble with the file pointer. #include <stdio.h> #include <string.h> int main(void) { char stone_color[82]; char column[82]; int row[82]; int i; int x; FILE *fp; fp = fopen...

Answer:

A segmentation fault is usually the result of trying to dereference a null pointer. Now, you do check...

Read more

RobDog at Yahoo! Answers Mark as irrelevant Undo

Shmget() help! Segmentation Fault....?

I have a project dealing with shared memory in c++ (using Solaris) and I have the following code to create my shared memory segment but it's giving me a segmentation fault when I try to create the shared memory. I printed out the value of shmget() and...

Answer:

You state that shmget failed (returned -1). This is because you try to open an non-existing shm region...

Read more

beTi at Yahoo! Answers Mark as irrelevant Undo

Getting a segmentation fault in linux terminal?

I was running the terminal on ubuntu and trying to downgrade my revo 3d hboot 1.50 to 1.40 if that helps. Anyways i put in the sudo -s command. Gained root. Then i typed chmod 755 downgrade whichw as the name of the file in my home folder. Last i typed...

Answer:

segfaults are often caused by mismatches in libraries . Try using the exact version was whatever the...

Read more

Demetriu... at Yahoo! Answers Mark as irrelevant Undo

C++ programming: Segmentation fault reading object pointers from a vector?

I've been trying to get a program running for a class I'm in and I've been stuck on the same spot forever! I get a segmentation fault from the last line of the following code - Does anyone know why? I suppose I should also be adding "delete ap;...

Answer:

The problem is that there are no elements in your vector, and you are calling the display function on...

Read more

john at Yahoo! Answers Mark as irrelevant Undo

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.