segmentation-fault

C sprintf causing a segmentation fault.

Hello, I am trying to pass in arguments to the a parent file that is supposed to create a child process for each pair of arguments. The child processes will add up each pair and return their sum to the parent process. If there is an odd number of arguments passed in, I add a 0 to the end of the argv array to make it even. This keeps hap...

Virtual Classes Segmentation Faults

I'm working on a graphic application. It makes significant use of virtual classes. I'm getting some segmentation faults that I'm having trouble debugging. The primary classes in this application are: Shape (a virtual class) Rectangle Polygon Circle Picture (essentially a collection of shapes) Here is a shortened copy of the applic...

PHP script causes segmentation fault then the browser asks me to download the .php file with nothing in it?

I've noticed an unusual problem with some of my php programs. Sometimes when visiting a page like profile.edit.php, the browser throws a dialogue box asking to download profile.edit.php page. When I download it, there's nothing in the file. profile.edit.php is supposed to be a web form that edits user information. I've noticed this o...

Seg Fault when using std::string on an embedded Linux platform

Hi, I have been working for a couple of days on a problem with my application running on an embedded Arm Linux platform. Unfortunately the platform precludes me from using any of the usual useful tools for finding the exact issue. When the same code is run on the PC running Linux, I get no such error. In the sample below, I can reliabl...

Customizing CGAL Kernel with my own Point class

I would like to use a custom Point class with the CGAL constrained delaunay triangulation. However, with the following MyPoint class (which should behave the exact same as a CGAL::Point_2 no?) I get segmentation faults. It works perfectly if I set the Point_2 typedef inside MyKernel to CGAL::Exact_predicates_inexact_constructions_kernel:...

Segmentation fault on the server, but not local machine

As stated in the title, the program is working on my local machine (ubuntu 9.10) but not on the server (linux). It's a grid hosting hosting package of godaddy. Please help.. Here is the code: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { long offset; FILE *io; unsigned char found; unsigned l...

Bewildering SegFault involving STL sort algorithm.

Hello everybody, I am trying to recreate the program in Column 15 of programming pearls using the STL. I am trying to create a suffix array using a string and a vector of indices. I record the list of words that I read in a string called input that acts as a list of words separated by ' ' that I read from stdin at the beginning of the...

file doesn't open, running outside of debugger results in seg fault (c++)

Hello (and thanks in advance) I'm in a bit of a quandry, I cant seem to figure out why I'm seg faulting. A couple of notes: It's for a course -- and sadly I am required to use use C-strings instead of std::string. Please dont fix my code (I wont learn that way and I will keep bugging you). please just point out the flaws in my ...

Problems with Linked List in C

Hey everyone, I am new to C and I am working on an XOR linked list for a project. I have most of the code done, but I can't seem to get the delete function of the list to work properly. It seems able to delete some numbers, but not any number you pass into the function. Could anyone experienced with C take a look and possibly point out w...

Why is Apache seg faulting?

We have a production server that seems to Seg Fault a few times every day. The fault is picked up by Apache and logged in the error log - but there seems to be no traffic around the time. If it's a request generating the fault then it looks like it happens before any other logging is made so I can't see how it's happening so it's very ha...

Why does this generate a segmentation fault?

#include<stdio.h> void foo(int **arr) { arr[1][1]++; } main() { int arr[20][20]; printf("%d\n",arr[1][1]); foo((int**)arr); printf("%d\n",arr[1][1]); } ...

wats SIGSEGV, Segmentation fault in QT

I have a QT program which displays the data it receives over UDP. It works fine for around 30 seconds but after a while it gives Segmentation Fault and crashes. This 30 seconds is also not fixed. I used the debugger and got this Program received signal SIGSEGV, Segmentation fault. 0x003c6fd4 in ?? () from /usr/lib/libQtGui.so.4 Can a...

Getting Segmentation Fault in C++, but why?

I am getting segmentation fault in this code but i cant figure out why. I know a segmentation fault happens when a pointer is NULL, or when it points to a random memory address. q = p; while(q -> link != NULL){ q = q -> link; } t = new data; t -> city = cityName; t -> latitude = lat;...

R segfault when running via Rpy on linux

I'm running R via Rpy on a redhat linux distribution. Periodically I'll encounter this error message: *** caught segfault *** address (nil), cause 'unknown' And the entire program dies right there. It usually occurs when I run a lot of regression r.lm(). But by simply running the identical code again, the problem may or may not go awa...

Segmentation fault before return

Hi, Why does the following code seg fault before returning: int main() { char iD[20]; memset (iD, 0, 20); char* prefix; srand (time(NULL) ); int iPrefix = rand()%1000000; sprintf(prefix, "%i", iPrefix); int len = strlen(prefix); char* staticChar = "123456789"; //set prefix into ID memcpy(iD, prefix, len); // append static value mem...

Recursive main() - why does it segfault?

Why does the following program segfault? int main() { main(); } Even though it is a recursion that does not end and is therefore invalid by definition, I don't see why it segfaults (gcc 4.4.3 and clang 1.5 (trunk)). ...

passing an array of structures (containing two mpz_t numbers) to a function

Hello, I'm working on some project where I use the type mpz_t from the GMP C library. I have some problems passing an array of structures (containing mpz_ts) adress to a function : I wille try to explain my problem with some code. So here is the structure : struct mpz_t2{ mpz_t a; mpz_t b; }; typedef struct mpz_t2 *mpz_t2;...

Can some tell me why I am seg faulting in this simple C program?

I keep on getting seg faulted after I end my first for loop, and for the life of me I don't why. The file I'm scanning is just 18 strings in 18 lines. I thinks the problem is the way I'm mallocing the double pointer called picks, but I don't know exactly why. I'm am only trying to scanf strings that are less than 15 chars long, so I do...

Why am I getting a segmentation fault?

If I pass a value greater than 100 as the second argument to BinaryInsertionSort, I get a segmentation fault. int BinarySearch (int a[], int low, int high, int key) { int mid; if (low == high) return low; mid = low + ((high - low) / 2); if (key > a[mid]) return BinarySearch (a, mid + 1, high, key); ...

check whether mmap'ed address is correct

I'm writing a high-loaded daemon that should be run on the FreeBSD 8.0 and on Linux as well. The main purpose of daemon is to pass files that are requested by their identifier. Identifier is converted into local filename/file size via request to db. And then I use sequential mmap() calls to pass file blocks with send(). However sometime...