segmentation-fault

Whats the difference between the two command lines? (SegFault)

I have written a code that maps to a shared memory location,so that the first program opens a shared memory block and stores some data in it.And the second program reads the shared data. Whats the difference between the two command lines: 1. if(argc<2) { printf("USAGE:%s text-to-share\n",argv[0]); } This code gives me a Segm...

Why does this program cause a segfault?

hi guys i am new so i am sure you will help i have some trouble with skip list here is code #include <stdio.h> #include<stdlib.h> #include<time.h> #include <string.h> #define P 0.5 #define MAX_LEVEL 6 struct sn{ int value; struct sn **forward; }; typedef struct sn skipnode; typedef struct{ skipnode *...

Segmentation fault c++ templates

I wrote my first ever C++ template code on expandable array and I am getting a segmentation fault! After an hour of debugging I have realized that I need help. Something is wrong with the constructor or the destructor I think but not sure. The code is on pastie ready to be compiled. http://pastie.org/1150617 /* Expandable array in C++ ...

C segmentation faults due to fopen(). How to trace and what to look for?

Hi, (this was asked on ffmpeg-devel list, but counted way offtopic, so posting it here). ffmpeg.c loads multiple .c's, that are using log.c's av_log -> av_log_default_callback function, that uses fputs; void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) { ... snprintf(line, sizeof(line), "[%s @ %p] ", (*par...

OpenCV 2.1 Python Bindings Segfaulting

Hello I have a problem when grouping the OpenCV's functions in functions of my own and getting segmentation fault. Even with code as simple as this def acquire_imagen(): capture = cv.CaptureFromCAM( 0 ) img = cv.QueryFrame( capture ) return img img = acquire_image() print img[0,0] If I call the same instructions outside the fun...

Not so Useful Error -- Segmentation Fault (Core Dump) in Homework Assignment

When compiling a program containing this particular function, /* * Function read_integer * * @Parameter CHAR* stringInt * * Parameter contains a string representing a struct integer. * Tokenizes the string by each character, converts each char * into an integer, and constructs a backwards linked list out * of the digits. * * @...

Methodology for fixing Segmentation faults in C++

I am writing a cross-platform C++ program for Windows and Unix. On the Window side, the code will compile and execute no problem. On the Unix side, it will compile however when I try to run it, I get a segmentation fault. My initial hunch is that there is a problem with pointers. What are good methodologies to find and fix segmentation ...

How many bits to ignore when checking for NULL?

The following crashes with a seg-V: // my code int* ipt; int bool set = false; void Set(int* i) { ASSERT(i); ipt = i; set = true; } int Get() { return set ? *ipt : 0; } // code that I don't control. struct S { int I, int J; } int main() { S* ip = NULL; // code that, as a bug, forgets to set ip... Set(&ip->J); // gobs o...

OpenCl cleanup causes segfault.

Hello! I constructed my own little Opencl example using different sources on the net. The actual kernel works, and I get the output I want, but the cleanup functions, I found in one of the examples, cause segfaults. What did I do wrong? #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <CL/cl.h> //opencl #define CL_CH...

Why does this program give segmentation fault?

Hi, It's a beginners question: Why is this breaking/giving an error? #include <stdio.h> #include <stdlib.h> #include <string.h> char *strtrim_right(char *p) { char *end; int len; len = strlen( p); while (*p && len) { end = p + len-1; if(isalpha(*end)) *end =0; else break; } return(p);...

Request is terminating without response

In an site I'm currently writing, I'm facing a strange, mind-boggling behaviour: after seconds of 100% CPU usage, the server is responding nothing, only closing the connection. If I limit down the work of this request, it starts working as normal. XDebug is showing that the bottleneck is not SQL, but rather CPU usage (some function call...

Simple OpenGL code always causes a segmentation fault (C++ on Ubuntu, virtual machine)

I just started trying to use OpenGL in C++ for a class(I have previously used it in Java a fair amount). And I started off trying to write something substantial, I couldn't get that to stop Seg faulting so I wrote this piddly little piece of code which is nearly a line for line copy from an example in the first chapter of the red book. ...

What's the cause of my segmentation fault?

I'm trying to write a program that reads in entries from a file into a dynamically allocated array of structures using input redirection. My program compiles fine but I'm getting a segmentation fault and I'm having trouble finding the cause. Here's my Program: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef str...

Segmentation fault after declaring a variable inside structure

I am currently working on a project using network simulator 2. When I add variable inside the structure re_block, the program compiles but gives me segmentation fault during runtime. When i declare the variable as static there is no runtime error. Someone please explain this. struct re_block { # if __BYTE_ORDER == __BIG_ENDIAN u_int16_...

Core dumped?­­­­

Possible Duplicate: Why core dump file is generated ? When my programs segfault, I get this message on stderr: Segmentation fault Sometimes, however, I see this instead: Segmentation fault (core dumped) What is the 'core'? Is it useful for debugging? What triggers it to be dumped? Where are these dumps located? ...

Segmentation Error in Rails

Hi, I am working on Windows XP machine. I have started to create an application in rails but I am getting Segmentation fault error. Below are the ruby & rails version I am using. C:\Ruby>ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32] C:\Ruby>rails -v Rails 2.3.8 When ever I run the server, I am getting this error. C...

Segmentation Fault

I'm getting a segmentation fault on this statement, when I comment it out I don't get a segfault: this->rows += 1; The whole method is like so: template <class T> void Table<T>::push_back_row(std::vector<T> & vec){ //Create a new row structure T ** temp; temp = new T*[this->rows+1]; for(uint i = 0; i < rows; i++){ //Rese...

Segmentation fault using FastDelegate

I've got a problem with my test code. It compiles well, but when I try to call delegate, program crashes. #include "..\libs\FastDelegate\FastDelegate.h" #include <string> #include <map> #include <iostream> typedef fastdelegate::FastDelegate1 <int, int> FuncPtr; struct Function { FuncPtr Ptr; int Param; Function() {}; Function (Fun...

Seg Fault with SOCI

So I haven't been coding in C++ for quite a while now, but I'm pretty sure this issue is related to SOCI and not some general knowledge of memory usage in C++. Here is the problem : I'm using SOCI to query a table and get a field, and the sql statement line always cause a Segmentation Fault. Which is quite troublesome... Here is the code...

Seg Fault when initializing array

Hi guys, I'm taking a class on C, and running into a segmentation fault. From what I understand, seg faults are supposed to occur when you're accessing memory that hasn't been allocated, or otherwise outside the bounds. 'Course all I'm trying to do is initialize an array (though rather large at that) Am I simply misunderstanding how to ...