2
голосов
6ответов
5150 просмотров

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 ...

0
голосов
2ответов
1242 просмотров

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....

0
голосов
3ответов
243 просмотров

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...

51
голосов
6ответов
110912 просмотров

What causes a SIGSEGV

I need to know the root cause of the segmentation fault (SIGSEGV), and how to handle it.

0
голосов
3ответов
119 просмотров

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; ...

5
голосов
3ответов
2929 просмотров

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...

14
голосов
3ответов
9993 просмотров

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...

2
голосов
5ответов
2988 просмотров

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 t...

10
голосов
6ответов
3520 просмотров

Segmentation fault question

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 this so?

0
голосов
3ответов
2592 просмотров

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++) { fo...

0
голосов
2ответов
1050 просмотров

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 { re...

1
голосов
6ответов
2721 просмотров

Pointer initialization and string manipulation in C

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, even...

5
голосов
6ответов
683 просмотров

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...

1
голосов
2ответов
3160 просмотров

JNI segmentation fault bug

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...

11
голосов
2ответов
32846 просмотров

What are segfault rip/rsp numbers and how to use them

When my linux application crashes, it produces a line in the logs something like: segfault at 0000000 rip 00003f32a823 rsp 000123ade323 error 4 What are those rip and rsp addresses? how do I use them to pinpoint the problem? do they correspond to something in the "objdump" or "readelf" outputs?...

0
голосов
7ответов
1855 просмотров

What is the reason for a segmentation fault with this C++ code using lists?

I have some complicated C++ code but the problem narrows down to doing a push_back on a list of structures: list<cache_page> cachedPages; void f() { cache_page cpage(a,b); cachedPages.push_back(cpage); } I have commented all the data members of the struct cache_page and still th...

3
голосов
8ответов
13442 просмотров

fclose() causing segmentation fault

I have a tab-delimited text file that I am parsing. Its first column contains strings of the format chrX, where X denotes a set of strings, e.g., "1", "2", ..., "X", "Y". These are each stored in a char* called chromosome, as the file is parsed. The text file is sorted on the first column lex...

8
голосов
6ответов
15238 просмотров

How can malloc() cause a SIGSEGV?

I have an odd bug in my program, it appears to me that malloc() is causing a SIGSEGV, which as far as my understanding goes does not make any sense. I am using a library called simclist for dynamic lists. Here is a struct that is referenced later: typedef struct { int msgid; int status;...

7
голосов
1ответов
14618 просмотров

std::string::assign() causes segfault

I have a std::vector<uint8_t> that contains strings at specific offsets. Here's a shortened dump: ... @128 00 00 00 00 00 00 00 00 73 6F 6D 65 74 68 69 33 ........somethin @144 38 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ng.............. @160 00 00 00 00 00 00 00 00 31 2E 32 2...

2
голосов
1ответов
3071 просмотров

How do I map a segfault instruction pointer address from /var/log/messages to an address/function in my .map file?

(My environment is 64-bit Ubuntu, my application is C++ compiled and linked with g++.) When an application does something like divide by zero or run a asm("int $3") left in the code, one of the following gets logged via syslog to /var/log/kern.log and /var/log/messages: Sep 10 18:06:47 VM kerne...

3
голосов
3ответов
66119 просмотров

Putting user input into char array (C Programming)

I need to read the input from the console and put it into an array of chars. I wrote the following code, but I get the following error: "Segmentation Fault" #include <stdio.h> #include <stdlib.h> int main() { char c; int count; char arr[50]; c = getchar(); coun...

3
голосов
5ответов
1083 просмотров

Writing into c-string

my code segfaults and I don't know why. 1 #include <stdio.h> 2 3 void overwrite(char str[], char x) { 4 int i; 5 for (i = 0; str[i] != '(gdb) run Starting program: /tmp/x/x Breakpoint 1, overwrite (str=0x8048500 "abcde", x=88 'X') at x.c:5 5 for (i = 0; str[i] != '12...

3
голосов
3ответов
4022 просмотров

Help interpreting gdb: segfault in function

I am trying to debug a segfault, and I have this output from gdb: (gdb) n Program received signal SIGSEGV, Segmentation fault. 0x08048af9 in parse_option_list (ptr=0x6f72505f <Address 0x6f72505f out of bounds>, box_name=0x696d6978 <Address 0x696d6978 out of bounds>, option_list=0x31...

8
голосов
2ответов
4142 просмотров

SetJmp/LongJmp: Why is this throwing a segfault?

The following code summarizes the problem I have at the moment. My current execution flow is as follows and a I'm running in GCC 4.3. jmp_buf a_buf; jmp_buf b_buf; void b_helper() { printf("entering b_helper"); if(setjmp(b_buf) == 0) { printf("longjmping to a_buf"); ...

0
голосов
5ответов
557 просмотров

C++ segmentation-fault problem

I've gotten a crash in my program which seems fine to me, of course my program says otherwise, which confuses me. This snippet of my function I am currently working on: for(int k = 0; k < dictionary[k].size(); k++) { //"i" represents the fragment's first character...

1
голосов
1ответов
389 просмотров

TokyoCabinet: Segmentation fault at hdb->close()

I'm stuck at a Segmentation fault after inserting about 8 million records in a TC Hash Database. After everything is inserted I close the DB but I caught a Segmentation Fault at this part of the code (tchdb.c): static void tchdbsetflag(TCHDB *hdb, int flag, bool sign){ assert(hdb); char *fp ...

3
голосов
5ответов
22506 просмотров

Trying to use execvp() in C with user input in unix

I'm trying to make a program that will prompt the user for a command, then use exec to execute that command. For instance if they gave me "ls -la" I would have to execute that command. I've tried the following code: #include <stdio.h> #include <unistd.h> #include <string.h> i...

0
голосов
7ответов
1159 просмотров

Random segfaults in C++

I'm new to C++ and I haven't a clue where to start, so I uploaded the code to a pastebin because there is a lot of it. This code compiles fine, and doesn't give off a warning, even with gcc's -Wall option. It's supposed to generate all prime numbers up to a number given as a command line parame...

1
голосов
1ответов
1344 просмотров

Is it possible somehow "rescue" segmentation fault on Ruby

I have a Ruby script, which uses one external lib. Sometimes script exits with segmentation fault, when uses this lib and I must to rerun it. Is it possible to somehow rescue this error by extracting fragment, which has dangerous code to separate process or something like that? Thanks

1
голосов
3ответов
1470 просмотров

Trouble finding the source of my segfault

EDIT: Problem solved. This was (yet another) situation where the problem wasn't really where it looked like it was. The clue was the use of @0xfeeefefe as a pointer to an object. This is an address that is returned by a windows API function when freeing memory... indicating that the object that w...