segmentation-fault

Getting segmentation fault after destructor

I'm making a small file reading and data validation program as part of my TAFE (a tertiary college) course, This includes checking and validating dates. I decided that it would be best done with a seperate class, rather than integrating it into my main driver class. The problem is that I'm getting a segmentation fault(core dumped) afte...

What's the bug in the following code ?

#include <iostream> #include <algorithm> #include <vector> #include <boost/array.hpp> #include <boost/bind.hpp> int main() { boost::array<int, 4> a = {45, 11, 67, 23}; std::vector<int> v(a.begin(), a.end()); std::vector<int> v2; std::transform(v.begin(), v.end(), v2.begin(), boost::bind(std::multiplies<int>(), _1, 2)); st...

Why does it NOT give a segmentation violation?

The code below is said to give a segmentation violation: #include <stdio.h> #include <string.h> void function(char *str) { char buffer[16]; strcpy(buffer,str); } int main() { char large_string[256]; int i; for( i = 0; i < 255; i++) large_string[i] = 'A'; function(large_string); return 1; } It's compiled and ...

Segfault in a matrix code using new

Hi all I created a simple class in C++ which has a private dynamic array. In the constructor I initialize the array using new and in the destructor I free it using delete. When I instantiate the class using Class a = Class(..); it works as expected, however it seems I cannot instantiate it using the new operator (Like Class *a = new Cl...

Interpreting segfault messages

What is the correct interpretation of the following segfault messages? segfault at 10 ip 00007f9bebcca90d sp 00007fffb62705f0 error 4 in libQtWebKit.so.4.5.2[7f9beb83a000+f6f000] segfault at 10 ip 00007fa44d78890d sp 00007fff43f6b720 error 4 in libQtWebKit.so.4.5.2[7fa44d2f8000+f6f000] segfault at 11 ip 00007f2b0022acee sp 00007fff368ea...

Segmentation fault

#include<stdio.h> #include<zlib.h> #include<unistd.h> #include<string.h> int main(int argc, char *argv[]) { char *path=NULL; size_t size; int index ; printf("\nArgument count is = %d", argc); printf ("\nThe 0th argument to the file is %s", argv[0]); path = getcwd(path, size); printf("\nThe current working directory...

MemSet & MemCopy

I'm writing a memory allocator, and I need a way to store an integer inside of a chunk of memory. This integer will represent the size of the block so I can navigate to the end given the pointer to the beginning. Here's my test example: // EDIT: Declared space for testInt int* testInt = new int; head_ptr = (char*) malloc(4*1024*1...

Why do i get segfault at the end of the application after everything's been done properly ?

#include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char pass[] = "m4ak47"; printf("Vnesi password: \t"); scanf("%s", stole); if(strncmp(stole, pass, sizeof(pass)) != 0) { printf("wrong password!\n"); exi...

Why does my program occasionally segfault when out of memory rather than throwing std::bad_alloc?

I have a program that implements several heuristic search algorithms and several domains, designed to experimentally evaluate the various algorithms. The program is written in C++, built using the GNU toolchain, and run on a 64-bit Ubuntu system. When I run my experiments, I use bash's ulimit command to limit the amount of virtual memo...

Object does not exist after constructor?

Hello, I have a constructor that looks like this (in c++): Interpreter::Interpreter() { tempDat == new DataObject(); tempDat->clear(); } the constructor of dataObject does absolutely nothing, and clear does this: bool DataObject::clear() { //clear the object if (current_max_id > 0) { inde...

segfault during fclose()

fclose() is causing a segfault. I have : char buffer[L_tmpnam]; char *pipeName = tmpnam(buffer); FILE *pipeFD = fopen(pipeName, "w"); // open for writing ... ... ... fclose(pipeFD); I don't do any file related stuff in the ... yet so that doesn't affect it. However, my MAIN process communicates with another process through shared mem...

QPlainTextEdit segmentation fault

Hi, All! I have some Qt application with QPlainTextEdit in Tab widget. When try to make a pointer on it QPlainTextEdit *w = (QPlainTextEdit*)ui->tabWidget->widget(0) and call a document() method w->document() I get a segfault. But if i call document directly, e.g. ui->mainEdit->document(), then everything works fine. Can anybo...

Segfault when calling a method c++

I am fairly new to c++ and I am a bit stumped by this problem. I am trying to assign a variable from a call to a method in another class but it always segfaults. My code compiles with no warnings and I have checked that all variables are correct in gdb but the function call itself seems to cause a segfault. The code I am using is roughly...

seg fault at the end of program after executing everything?

Hello all, I wrote a quick program which executes every statement before giving a seg fault error. struct foo { int cat; int * dog; }; void bar (void * arg) { printf("o hello bar\n"); struct foo * food = (struct foo *) arg; printf("cat meows %i\n", food->cat); printf("dog barks %i\n", *(food->dog)); } void main(...

memcpy segmentation fault on linux but not os x

I'm working on implementing a log based file system for a file as a class project. I have a good amount of it working on my 64 bit OS X laptop, but when I try to run the code on the CS department's 32 bit linux machines, I get a seg fault. The API we're given allows writing DISK_SECTOR_SIZE (512) bytes at a time. Our log record consists...

Segmentation fault in a function to reverse a singly linked list recursivley.

I am implementing a function to recursively reverse a linked-list, but getting seg-fault. typedef struct _node { int data; struct _node *next; } Node, *NodeP; NodeP recursiveReverseList(NodeP first){ if(first == NULL) return NULL; if(first->next == NULL) return first; NodeP rest = recursiveReverseList(first->next); r...

scanf segfaults and various other anomalies inside while loop

while(1){ //Command prompt char *command; printf("%s>",current_working_directory); scanf("%s",command);<--seg faults after input has been received. printf("\ncommand:%s\n",command); } I am getting a few different errors and they don't really seem reproducible (except for the segfault at this point >.<). This code wo...

Using HandVU with OpenCV on Mac OS X 10.6.3

Hi, I've tried to user HandVU with OpenCV but when I tried to run "hvOpenCV config/default.conductor" I get a "Segmentation fault". Anybody know this problem? macbook:handvu-beta3 User$ hvOpenCV config/default.conductor will load conductor from file: config/default.conductor Segmentation fault I installed OpenCV through http://openc...

graphviz segmentation fault

Hi I'm building a graph with many nodes, around 3000. I wrote a simple python program to do the trick with graphviz, but it gives me segmentation fault and I don't know why, if the graph is too big or if i'm missing something. The code is: #!/usr/bin/env python # Import graphviz import sys sys.path.append('..') sys.path.append('/us...

Maddening Linked List problem

This has been plaguing me for weeks. It's something really simple, I know it. Every time I print a singly linked list, it prints an address at the end of the list. #include <iostream> using namespace std; struct node { int info; node *link; }; node *before(node *head); node *after(node *head); void middle(node *head, node *ptr); v...