segmentation-fault

Segmentation fault when instantiating object from particular library

I have an C++ application (heavily shortened down, shown below); #include <iostream> #include "MyClass.h" void foobar() { MyClass a; } int main(int argc, char** argv) { std::cout << "Hello world!\n"; return 0; } Where "MyClass" is defined in a statically linked library (.a). However, this application Segfaults the instant its ...

Signal 11 segfault on wait() system call?

I'm new to processes in *nix, and am working on a basic shell in C... in implementing pipes, I count the commands on the line and iteratively fork() a new process. At the end of each iteration I wait() on the child before proceeding to the next command. This was working fine, but I've apparently changed something to break it: Program ...

Segfault when assigning one pointer to another

My brain has never really quite grasped linked lists and the finer points of pointers but I'm trying to help out a friend with some C++ assignments. (And before I go any further, yes, there is std::list but I'm looking for an academic answer, and maybe something that will make linked lists more understandable to he and myself). What we ...

PHP's preg-match_all causing Apache Segfault

Hi folks, I'm using two regular expressions to pull assignments out of MySQL queries and using them to create an audit trail. One of them is the 'picky' one that requires quoted column names/etc., the other one does not. Both of them are tested and parse the values out correctly. The issue I'm having is that with certain queries the 'p...

What could be wrong with this?

BTW: I found the problem: (See my answer below) When I build my program at home it works fine, but when I use my universities system is crashing on me. When I go at it with GDB I get this: (gdb) r t.c- Starting program: /home/shro8822/p5/c- t.c- *--Code Gen Function: main *--in function 'main' variable offsets start at 2 Program re...

Bizarre/Random Segfault in C

EDIT: Clarifying. fout is is a FILE*. (I thought this was irrelevant since that line clearly compiles) there is A LOT of code above these last few lines; I guess I could dump them all but I imagine you're not overly interested in debugging my stuff. I'm more interested, generally, in what could possibly occur that would segfault at...

Segmentation fault in Zend_Tool

I'm using Ubuntu 9.04 and I applied this tutorial But I'm still getting this error: berkerpeksag@berkerpeksag:~$ zf show version Segmentation fault What do I miss? Thanks. ...

segfault when copying an array to a vector in Linux

Hi, I'm trying to debug a legacy code written for Linux. Sometimes the application gets a segfault when it reaches the memcpy call in the following method: std::vector<uint8> _storage; size_t _wpos; void append(const uint8 *src, size_t cnt) { if (!cnt) return; if (_storage.size() < _wpos + cnt) _storage.resize(_wpos + cnt); ...

c segmentation fault structure

I have a structure called table, I just want to create a table, like constructor in java, but when i call this function in main, it gives segmentation fault struct table *create(char *name,int number,char *s_name) { struct table *newTable; newTable->name = name; newTable->number = number; newTable->s_name = s_name; return newT...

segmentation fault while assigning structure members in c

Hi, I have two structure in c struct data{ char *name; }; struct lst{ struct lst *next; struct table *data; }; when I'm trying to assign a name like l->data->name = d->name; printf("%s",l->data->name); it gives segmentation fault. So is it because read-only memory or caused by another reason ? ok I solved the problem : ) ...

Segfault in atoi(str)

I'm new to the C/C++ game so I assume I'm making a rookie mistake: int main(){ char* clen; clen = getenv("CONTENT_LENGTH"); if (clen==NULL){ cout << "No such ENV var: CONTENT_LENGTH"<<endl; exit(0); } int cl = 0; cl = atoi(clen); if (cl < 1){ return inputPage(); } // if there is no content, we assume tha...

segmentation fault when using pthreads , in a nondeterministic manner

The problem is that when I run the code below, on a single core, sometimes it runs correctly,and sometimes I get segmentation fault. Probably this problem will occure more frequently on a multi-core machine. I need to know where this non-determinism is introduces in my program and how can I resolve it.thanks. int numThreads = 4; class...

Segmentation fault when executing program compiled from x86 assembly?

Hi everybody! I'm new to assembly language and I have to implement a function, in my case sin(x), that could be called from a C source file. I have to make 2 separate files: *.c and *.s When compiling through gcc on ubuntu all good, but when the program executes it gives me the error "Segmentation fault"... To compile I type: gcc -c -o...

Is there a point to trapping "segfault" ?

I know that, given enough context, one could hope to use constructively (i.e. recover) from a segfault condition. But, is the effort worth it? If yes, in what situation(s) ? ...

std::vector reserve method fails to allocate enough memory

Hi, I have a buffer class in my C++ application as follows: class Buffer { public: Buffer(size_t res): _rpos(0), _wpos(0) { _storage.reserve(res); } protected: size_t _rpos, _wpos; std::vector<uint8> _storage; } Sometimes using the constructor fails because its unable to allocate the required memory ...

segmentation fault in overloading operator =

Hi, I just got a seg fault in overloading the assignment operator for a class FeatureRandomCounts, which has _rects as its pointer member pointing to an array of FeatureCount and size rhs._dim, and whose other date members are non-pointers: FeatureRandomCounts & FeatureRandomCounts::operator=(const FeatureRandomCounts &rhs) { i...

Segmentation fault

I have come across a problem while writing a fairly simple program. I have a statically allocated vector as a global variable and in a function I'm trying to change the values of the elements and that is when the program stops and says segmentation fault. The code is something like this: int a[10] = {0,0,0,0,0,0,0,0,0,0}; ... int bla(...

sqlstm.sqpadto = sqlstm.sqadto causing segmentation fault

When and how sqlstm.sqpadto = sqlstm.sqadto can cause segmentation fault? I am getting segmentation fault and getting this line in the core file. I am using proC ...

Win32 DDK: Is calling API from driver interrupt wrong?

Note: This is not a problem i'm experiencing, but it is something i'd like to understand (just because i want to be a better person, and to further the horizon of human understanding). In the bonus chapter of Raymond Chen's book, Raymond gives the example of a bug in a sound card driver: The original function, called...

Executing machine code in memory

I'm trying to figure out how to execute machine code stored in memory. I have the following code: #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { FILE* f = fopen(argv[1], "rb"); fseek(f, 0, SEEK_END); unsigned int len = ftell(f); fseek(f, 0, SEEK_SET); char* bin = (char*)malloc(len); ...