sigsegv

runtime error (SIGSEGV)

hi, i would be happy to know why i got this error for the problem http://www.codechef.com/problems/AXR1P2 in codechef.com and my code is... #include<stdio.h> #include<stdlib.h> int main() { int *num=0,n=0,i=0,max=0;char *s=""; int sum[9]={1,5,14,20,25,31,32,38,39},dsum[9]={1,7,8,14,19,25,26,32,33},unitdig=0; do { gets(s); *(num+i)=(in...

C SIGSEGV Handler & Mprotect

I'm constructing a program which uses mprotect() to restrict a block of memory from accessing. When the memory is requested, a SIGSEGV is thrown which I listen for using a signal() call. Once the SIGSEGV has been detected, I need to somehow access the pointer to the memory that was requested (that threw the fault) and the size of the s...

What free tools or strategies can help debug a multi-threading corruption bug?

I have a client server application with multi-threading. The server side is failing with a std::list getting corrupted resulting in a SEGV. I suspect that there is some kind of cross thread timing issue going on where the two threads are updating the std::list at the same time and causing it to be corrupted. Please suggest free tools ...

SIGSEGV problem

I'm designing a protocol (in C) to implement the layered OSI network structure, using cnet (http://www.csse.uwa.edu.au/cnet/). I'm getting a SIGSEGV error at runtime, however cnet compiles my source code files itself (I can't compile it through gcc) so I can't easily use any debugging tools such as gdb to find the error. Here's the stru...

handle SIGSEGV in Linux?

Hi all, I need handle the SIGSEGV in my Linux app. The reason is some clean up(3-partry lib) must be done before generate core-dump. What is more, the clean up must be performed in the context of calling thread, cannot do in signal handler. So I plan in signal handler to pass the control to the calling thread, after the clean up fini...

Segfault (possibly due to casting)

I don't normally go to stackoverflow for sigsegv errors, but I have done all I can with my debugger at the moment. The segmentation fault error is thrown following the completion of the function. Any ideas what I'm overlooking? I suspect that it is due to the casting of the sockaddr to the sockaddr_in, but I am unable to find any mistak...

Address of instruction causing SIGSEGV in external program

I want to get address of instruction that causes external program to SIGSEGV. I tried using ptrace for this, but I'm getting EIP from kernel space (probably default signal handler?). How GDB is able to get the correct EIP? Is there a way to make GDB provide this information using some API? edit: I don't have sources of the program, onl...

C: sprintf leads to SIGSEGV core via an strlen

Hi, My C application has the following two lines: char buf[1024]; sprintf(buf, "%s/game/rabbit/habit/cmd/talkPipe", getenv("APPLICATION_PATH")); The application sporadically crashes with SIGSEGV in the following manner: strlen(ff2ba231, 0, ffbfe1d0, 10, 7fff24d7, 0)+0x50 sprintf(ffbfe2a4, ff2ba231, 0, 74656400, 12, ff362ef2)+0x24 Ra...

Coming back to life after Segmentation Violation

Is it possible to restore the normal execution flow of a C program, after the Segmentation Fault error? struct A { int x; }; A* a = 0; a->x = 123; // this is where segmentation violation occurs // after handling the error I want to get back here: printf("normal execution"); // the rest of my source code.... I want a mechanism s...

Crash (SIGSEGV) in Core Data internal methods

Hi, I got a crash report and the crashing thread's call stack all show Apple's code. From the looks of it, Core Data's undo manager is accessing an invalid pointer in -[NSManagedObject(_NSInternalMethods) _newSnapshotForUndo__] + 356. I've googled the point of crash and the only other similar crash log I found was from Sequel Pro cras...

Converting signal to NSException only work the first time

It seems that when BSD signals are converted to thrown exceptions, it only work the first time but not subsequent times. I tried to convert signals to exception via the following call I made in the main method just before calling NSApplicationMain : [[NSExceptionHandler defaultExceptionHandler] setExceptionHandlingMask:NSHandleUncaught...

Can I write-protect every page in the address space of a Linux process?

I'm wondering if there's a way to write-protect every page in a Linux process' address space (from inside of the process itself, by way of mprotect()). By "every page", I really mean every page of the process's address space that might be written to by an ordinary program running in user mode -- so, the program text, the constants, the ...

Why would one crash log symbolicate and not another?

I have two crash logs from a iPhone application in XCode Organizer. Both occurred within 20 minutes of each other, on the same device, running the same build of the application. While one has been symbolicated the other has not. The unsymbolicated log has type and codes: Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000,...

A lot of SIGSEGV while strace'ing java process

Interesting stuff occurred while I debug one of the unit tests on CI server (maven build actually). I connect to java process with strace -ff -e trace=network -p [pid] to trace network activity of build process. And that's what I saw: Process 26324 attached Process 26325 attached (waiting for parent) Process 26325 resumed (parent 26312 ...

GDB Quirks with Thread Process

I am debugging a process with multiple threads in GDB. I compiled the sole source file with the -g flag. However, while running in GDB, the following scenario occurs: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7fe2b70 (LWP 2604)] 0x00000011 in ?? () Prior to the switch, the particular thread executes...