segmentation-fault

JNI segmentation fault bug

Hi, there is this morphological analyzer (open source, written in OCml) named ocamorph. download and make instructions here The java binding is buggy and I'll have to fix it and after a few hours of struggle now it seems to me it'll take a few days to fix it as I'm not familiar with C, JNI, OCml and this particular software. Here you c...

Waiting with a crash for a debugger?

When an assert fails or there is a segmentation fault, it would be very convenient that one of the following happens: Program ask whether to run a debugger. Program waits with crashing until debugger is attached. Program leaves something (core dump?) that we can resume execution from this point and investigate. The question is quite ...

Pointer initialization and string manipulation in C...

Hi, I have this function which is called about 1000 times from main(). When i initialize a pointer in this function using malloc(), seg fault occurs, possibly because i did not free() it before leaving the function. Now, I tried free()ing the pointer before returning to main, but its of no use, eventually a seg fault occurs. The above...

segmentation fault while inserting into priority queue

My definition of priority queue is: template<typename Node, typename Cmp = std::less<Node> > struct deref_compare : std::binary_function<Node*,Node*,bool> { deref_compare(Cmp const& cmp = Cmp()) : cmp(cmp) {} bool operator()(Node* a, Node* b) const { return (a->getfValue()> b->getfValue()); } private: Cmp c...

runtime error (SIGSEGV)

#include<iostream> #include<string> using namespace std; int main() { char arr[1000][80]; char output[1000][80]; int n,i,j; int num[1000]; cin>>n; for(i=0;i<n;i++) { cin>>num[i]; cin>>arr[i]; } for(i=0;i<n;i++) { for(j=(num[i]-1);j<(strlen(arr[i])-1);j++) { arr[i][j]=arr[i][j+1]...

Segmentation fault doubt

I have observed that sometimes in C programs, if we have a printf in code anywhere before a segmentation fault, it does not print. Why is it so? ...

How can I track down a segmentation fault in a Cocoa application?

I'm having a problem with a Cocoa application I am writing. It has to parse a timestamped file that is updated every hour, and during testing it keeps crashing consistently at around 11:45 PM due to a segmentation fault. I'm assuming I must be messaging an object that has been deallocated. What tools are provided with the Xcode install t...

sort function C++ segmentation fault

In this code, for vector size, n >=32767, it gives segmentation fault, but upto 32766, it runs fine. What could be the error? This is full code. #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<utility> #include<algorithm> #include<sys/time.h> using namespace std; #define MAX 100000 bool compare(pair<int,int>...

Segmentation fault only when I redirect stdout to /dev/null ?

I've got a C++ unit test that produces useful output to stderr, and mostly noise (unless I'm debugging) to stdout, so I'd like to redirect the stdout to /dev/null. Curiously enough, doing this seems to cause a segmentation fault. Is there any reason why code might seg fault with "> /dev/null" and run fine otherwise? The output is prod...

Why can't the Nodes be linked together?

EDIT: Is it possible to NOT use new? (do not dynamically allocating memory) I think it is push that is wrong, but I don't know where, how, and why. here is the code: struct Node { string fileName; Node *link; }; int size(Node *&flist) { int count = 0; Node *tempPtr = flist; while (tempPtr != 0) { count += 1; ...

How do I find out where an object was instanciated using gdb?

I'm debugging an application and it segfaults at a position where it is almost impossible to determine which of the many instances causes the segfault. I figured that if I'm able to resolve the position at which the object is created, I will know which instance is causing the problem and resolve the bug. To be able to retrieve this inf...

How can I add debugging symbols to Audacious?

I am writing a plugin for audacious, and I am experiencing random segfaults. I looked around and I found that I can process the program's core dumps with gdb. So I did that, and I got this output: http://pastebin.com/m7d0d663d As you can see, it says no debugging symbols where found anywhere. I want to compile audacious with debuggin...

Valgrind: Deliberately cause segfault

This is a mad-hack, but I am trying to deliberately cause a segfault at a particular point in execution, so valgrind will give me a stack trace. If there is a better way to do this please tell me, but I would still be curious to know how to deliberaly cause a segfault, and why my attempt didn't work. This is my failed attempt: long* p...

What are some of the general reasons for Memory Leak and Segmentation Fault ?

What are some of the general reasons for Memory Leakage and Segmentation Fault kind of errors ? ...

Why is this C code causing a segmentation fault?

I am trying to write code to reverse a string in place (I'm just trying to get better at C programming and pointer manipulation), but I cannot figure out why I am getting a segmentation fault: int main() { char* s = "teststring"; reverse(s); return 0; } reverse(char* s) { int i,j; char temp; for (i=0,j=(strlen...

Push Call to STL Queue<std::string> causes Segfault when String is read off socket

I'm using an STL Queue as an input queue, it's containing std::strings, which I have aliased as String using a typedef. I'm reading the input string off a socket - using Berkeley sockets. It is read into a char buffer array and then used to set a string which is passed to the queue. It only happens for the input queue - the output que...

Why the SIGSEGV?

Why is this code throwing up a SIGSEGV: int main() { unsigned long toshuffle[9765625]; unsigned long i; for (i=0; i< 1000; i++) toshuffle[i]= i; return 0; } Pointers will be appreciated. (No Pun intended :)) ...

ANSI C getc causes segfault on Linux but not OS X

I have some ANSI C code that I developed on my Mac, but when I tried running it on our school's Linux servers I get a segfault. The specific line that is causing me trouble is a getc from a file pointer. The file does exist. Here is the method in question: // inits lists with all data in fp file pointer // returns # of lines read int...

Segmentation fault when catching exceptions in a libpthread linked app ( linux, C++ )

Hi I have this piece of code here: These are functions used to create and stop a pthread: void WatchdogController::conscious_process_handler_start() { if ( debug ) cout << "WatchdogController: starting conscious process thread" << endl; cn_pr_thread_active = true; if ( pthread_create( &cn_pr_thread, NULL, conscious_proc...

Strange segmentation fault C++ in _vfprintf_r()

Someone please see my code at this link for input taken from this file( 2.2 mb file). This produces seg fault. By gdb, it shows seg fault in _vfprintf_r(). But when I comment line 41 and uncomment 38 (a null statement), there is no segmentation fault. line no 41 is just print statement. Someone please help. I am frustated and wasted a da...