segmentation-fault

At what point does the segfault occur?

Does the following code segault at array[10] = 22 or array[9999] = 22? I'm just trying to figure out if the whole code would execute before it seg faults. (in the C language). #include <stdio.h> int main(){ int array[10]; int i; for(i=0; i<9999; ++i){ array[i] = 22; } return 0; } ...

For loop missing several indexes with segfault

The output of the application (bottom) is as follows: Element index number: 0 Element contents: 22 Element index number: 1 Element contents: 22 Element index number: 2 Element contents: 22 Element index number: 3 Element contents: 22 Element index number: 4 Element contents: 22 Element index number: 22 Element contents: 134513712 Why...

segmentation fault on pthread_mutex_lock

hey, sorry to be a bother, but I need help urgently. I searched for this before I posted this question. I'm getting a segmentation fault when I try to do pthread_mutex_lock(&_mutex). This is really odd, I'm not sure what might have caused it. I have initialized _mutex in the constructor with pthread_mutex_init(&_mutex,NULL). anythi...

Segmentation fault - char pointer

In the code below, the line: *end = *front; gives a segmentation fault. I asked a similar question here but I'm not sure if this is because I have two copies of num. Please explain why it's seg-faulting. Thank you. #include <stdio.h> #include <stdlib.h> #include <string.h> char* getPalin(char* num); int main() { char* num = (c...

Xerces-C problems; segfault on call to object destructor

I've been playing around with the Xerces-C XML library. I have this simple example I'm playing with. I can't seem to get it to run without leaking memory and without segfaulting. It's one or the other. The segfault always occurs when I delete the parser object under "Clean up". I've tried using both the 2.8 & 2.7 versions of the l...

Weird "Bus error" in string::string constructor

I've been testing part of my code responsible for filling multimap object, when a weird error started to pop up: int SetPortName(string ID, string Name) cout << "ID: " << ID << " Name: " << Name; ... } works fine under non-root user in FreeBSD 5.4, but crashes with "Bus error" while ran under root. ...

Xcode "index is corrupt, will rebuild" message followed by "Segmentation fault" when running under root

Can anybody explain to me the cause of the following message, perhaps along with suggestions as to how to fix it? I'm running XCode under root using sudo <path to xcode because I need to debug a daemon that has to run as root. I've done this several times successfully, but now when I try to open the project in Xcode I get the following...

C Programming: seg faults, printf, and related quirks

As many young programmers do, I learned the usefulness of inserting numerous print-to-console statements of "here1," "here2," and so on at different points in code to figure out when my programs are going awry. This brute force debugging technique has saved me many, many times throughout my CS studies. However, when I started programming...

segfault after return 0;

I wrote a program to test my binary tree and when I run it, the program seems to crash (btree.exe has stopped working, Windows is checking for a solution ...). When I ran it through my debugger and placed the breakpoint on the function I suspect is causing it, destroy_tree(), it seemed to run as expected and returned back to the main fu...

C++/GLFW - The right way to use Mutex objects ?

Hi, I'm working on a simulation that uses multithreading extensively. The thing is that, until now i've never used any mutex objects to protect my data. And the result, is that i'm getting bunch of segmentation faults.. I'm trying to lock/unlock with mutex while : reading/writing but that causes me another segfault : #0 77D27DD2 ntdl...

Debugging a clobbered static variable in C (gdb broken?)

...

Segmentation fault operating a camera with MATLAB

I am using Matlab to operate a camera. It is an IDT SharpVision camera, and I am using the Matlab interface provided by the company. When I try to acquire an image, I get a segmentation fault. I have tried preallocating memory by creating an empty array for the image, but this does not work. This is the line of code that causes the...

linux: where's the "real" segmentation fault handler ?

If I read/write/jump to an ummapped address ie. .text .global _start _start: movl $1,%edx jmp *%edx this causes a segmentation fault. I wonder, what's the actual part of the system (kernel) that intercepts reads/writes to unmapped addresses (how ?) and throws the "user mode" signal ? ...

Segmentation fault when malloc/free appear in loop in C

Hi there, I have a program that basically looks like: typedef struct cpl_def { int A; int B; int OK; struct cpls *link; }cpls; int main(void) { int n1, n2; int num = 300; /* say */ int *a; ...

Not sure what is causing my segmentation fault - C++

Hi I have some experience with programming but I'm not very good with pointers. I've been trying to debug this program I've been working on but it keeps giving me a segmentation fault. My code is the following: #include <iostream> using namespace std; class hexagon { public: hexagon(); ~hexagon(); void setSide(int side, h...

RoR segfaults when accessing MySQL database

I'm running Ruby on Rails on a Solaris 10 server. I just reinstalled Ruby today to get things to work correctly with my MySQL system so I could add a new application I've been working on. I also updated my gems and the system. MySQL is the only thing in this system that hasn't been updated lately, that's at version 5.1.25. When I run th...

STL List to hold structure pointers

I have a structure called vertex and I created some pointers to them. What I want to do is add those pointers to a list. My code below, when it tries to insert the pointer into the list, creates a segmentation fault. Can someone please explain what is going on? #include <iostream> #include <list> #define NUM_VERTICES 8 using namesp...

Why Do I Get This Segmentation Fault In This PHP Command Line Script?

It's just a quick script to a message to what I call a 'mental log file'. Just to keep track of my thoughts when I drift off and get myself back to work. Anyway, it works alright most of the time, but every so often I get a segmentation fault. Heard of them in C, but never had them before in PHP. Here's the script: #!/usr/bin/php <?php...

Segfault when calling Gtkmm textBuffer->insert

I'm just learning about gtkmm for c++. I'm having trouble getting a simple TextBuffer to add a new line of text. I have a class called OutputBox which is an HBox with a TextViewer (called messages) and a TextBuffer (called textBuffer) in it. Here is a small chunck of the OutputBox class: OutputBox::OutputBox() { textBuffer = messages...

Linux mmap() error

I have a memory mapped file, from which I wish to parse the contents of the buffer. The mmap() returns success, and I can print out the buffer contents to a file using fprintf successfully. However, when I try to access the buffer as an array in my program directly, I get a segmentation fault. Why is this happening? Here is the code: ...