segmentation-fault

Seg fault vector<vector<list<Object*> > > push_back

I have a 3D vector defined like this... std::vector<std::vector<std::list<Object*> > > m_objectTiles; I have this code... void ObjectManager::AddObject( Object *object ) { m_objects.push_back( object ); m_objectTypes.insert( std::make_pair( ObjectAttorney::GetType( object ), object )); int x = ObjectAttorney::GetTileX( ob...

Retaining Common Prefix of two strings.....C Programming... Segmentation fault error......

char *strip_postfix(char *str1, char *str2) { int i; for(i=0; str2[i] != '\0'; i++) { if(str1[i] != str2[i]) { str1[i] = '\0'; break; } } return str3; } This code, is giving segmentation fault error at line str1[i] = '\0' during run time..... I think there is some memory allocation i...

Crazy C++ Vector iterator

I declare: typedef std::tr1::shared_ptr<ClassA> SharedPtr; And then: std::vector<SharedPtr> mList; And: typedef std::vector<SharedPtr>::iterator ListIterator; The return of mList.size() is 0, but when I use iterators, it iterates over the vector which is empty ! This is how I use the iterator: for(ListIterator it = mList.begin(...

std::list remove calling delete on pointer?

I ran valgrind on my program because of a segfault I can't figure out. It detected a problem here... Address 0x75c7670 is 0 bytes inside a block of size 12 free'd at 0x4024851: operator delete(void*) (vg_replace_malloc.c:387) by 0x805F6D8: std::list<Object*, std::allocator<Object*>::remove(O bject* const&) (new_allocator.h:95) T...

Storing a char in a char pointer

I have a global variable that is a *char. My main function header reads as int main(int argc, char* argv[argc]){...}. These two lines of code have to remain the way they are. The first argument of my main function is a number of type *char, that I convert to a char using atoi(...);. I am basically changing the ASCII value to its corresp...

Segmentation fault when returning a struct

I am trying to do a pretty simple thing - it is reading a file and then turning it into a char** splitting it into lines. However when I return a struct containing the char** and size i get Segmentation fault. I read here: http://stackoverflow.com/questions/3047163/c-segmentation-fault-before-during-return-statement that it's probably "m...

htmlParse() segfault error in R XML package: 'memory not mapped'

I am using R 2.11.1 and XML package 3.1-0, and I was going through an example from R2GoogleMaps when I encountered a segfault error. #library(RJSONIO) library(R2GoogleMaps) library(XML) #library(RCurl) load("b.rda") # find in the sampleDocs folder in source file of R2GoogleMaps center = c(mean(range(b$lat)), mean(range(b$long))) code ...

Rails segmentation fault when starting server?

Trying to get my rails 3 environment up and running and I keep encountering an error I can't get around. Any help would be great appreciated! Here is the problem: Patrick-Scotts-MacBook-Pro:~ PJS$ cd hope_app Patrick-Scotts-MacBook-Pro:hope_app PJS$ rails server /Users/PJS/.rvm/gems/ruby-1.9.2-rc2/gems/sqlite3-ruby-1.3.1/lib/sqlite3/sq...

c++ / gcc : segmentation fault at exit of main after catching a signal

The following code triggers a segmentation fault at exit. It seems to happen only if data is allocated on the stack between the 'sigaction' call and the loop : #include <signal.h> #include <unistd.h> bool end = false; void handler(int) { end = true; } int main() { struct sigaction sigs; sigs.sa_handler = handler; sigaction(SIGI...

Can't find reason for segmentation fault in my Fibonacci C++ code

My code is segfaulting. I can't understand why. It might have to do with the "fermatPrimeTest()" function I made. #include <iostream> #include <cmath> #include <cstdlib> #include "fib.h" using namespace std; bool fermatPrimeTest( unsigned long int p ) { if ( p % 2 == 0 ) { // if even return false; } else if ( p == 1 || p == ...

Cocktail Sort code segfaults - not sure why.

Hi there. I wrote a Cocktail Sort algorithm, and am testing it by generating random vectors of size 500 up to 10,000 - running it 10 times per vector. After about the 2000-3000 length vector mark, the code segfaults. I expect it isn't the test code as the same test is used for multiple sorting algorithms and it runs fine for every other ...

smallish string array assigment causes segmentation fault...

Hello, My original code (following) gives a seg fault at the string array assignment at about num_atoms=150,000: int num_atoms=dimension[0]*dimension[1]*dimension[2]*prim_lat.size(); double superlat[num_atoms][3]; string current_occ[num_atoms]; Thinking this was a first instance of me hitting a stack overflow issue, and thinking you c...

A thread-safe vector and string container?

I posted a previous question "Seg Fault when using std::string on an embedded Linux platform" where I got some very useful advise. I have been away on other projects since then and have recently returned to looking at this issue. To reiterate, I am restricted to using the arm-linux cross compiler (version 2.95.2) as this is what is supp...

"new" operator in multiple threads causes Segmentation Fault

This is related to an issue I have been discussing here and here, but as my investigations have led me away from the STL as the potential issue, and towards "new" as my nemisis, I thought it best to start a new thread. To reiterate, I am using an arm-linux cross compiler (version 2.95.2) supplied by the embedded platform vendor. When ...

Problem serializing an object tree with SplObjectStorage

I have implemented a simple Composite pattern using SplObjectStorage, like the example above: class Node { private $parent = null; public function setParent(Composite $parent) { $this->parent = $parent; } } class Composite extends Node { private $children; public function __construct() { $t...

Changing static array

Hi, I have a static variable declared in a file: static char *msgToUser[] = { "MSG1 ", "MSG2 ", }; Inside one of the methods of a class I'm doing this: void InfoUser::ModifyMsg( BYTE msgIdx, char *msgString ){ strncpy( msgToUser[ idx ], msgString, DISPLAY_SIZE ); } When I do the strncopy ...

Segfault on AIX from large C++ library

I'm trying to convert a Windows based library that my company produces to run on AIX. We are currently able to run it on Solaris and Linux but AIX is causing some additional issues. I'm not sure if this is an OS setup issue or a coding issue but I'm trying the coding approach first. The library exports some function using a C style con...

Fibonacci extension in c++ segfaulting

I'm trying to add the extension to the Fibonacci numbers to take into account negative indexes. The extension is Fib(-n) = (-n)^(n+1) * Fib(n) I have attempted to implement this in c++ but I'm running into a problem and I'm not sure how to get around it. #include <iostream> #include <math.h> int fib(int n) { if ( n < 0 ){ ...

How to debug an assembled program?

I have a program written in assembly that crashes with a segmentation fault. (The code is irrelevant, but is here.) My question is how to debug an assembly language program with GDB? When I try running it in GDB and perform a backtrace, I get no meaningful information. (Just hex offsets.) How can I debug the program? (I'm using NASM ...

C++ segmentation fault when trying to resolve a CORBA reference

Guys, When im trying to resolve a CORBA reference I receive a segmentation fault. Either im blind or I have done something really stupid for this not work. Im using ACE 5.7.9 TAO 1.7.9 for CORBA. Wondering if anyone can help me please ??? The segmentation fault seems to be happening on the line "serverRef = Corba::Orb::getOrb().resolve...