tags:

views:

364

answers:

7

Following this question:
Good crash reporting library in c#

Is there any library like CrashRpt.dll that does the same on Linux? That is, generate a failure report including a core dump and any necessary environment and notify the developer about it?

Edit: This seems to be a duplicate of this question

+2  A: 

Compile your code with debug symbols, enter unlimit coredumpsize in your shell and you'll get a coredump in the same folder as the binary. Use gdb/ddd - open the program first and then open the core dump. You can check this out for additional info.

+1  A: 

@Ionut This handles generating the core dump, but it doesn't handle notifying the developer when other users had crashes.

Nathan Fellman
+3  A: 

See Getting stack traces on Unix systems, automatically on Stack Overflow.

Ted Percival
I don't mean to rain on your parade, I intended this link as a supplementary resource. I'm still interested in ways to get the backtrace back to the developers (eg. kerneloops.org). So far it seems like gathering the environment and associated data is up to the individual developer.
Ted Percival
A: 

Note: there are two interesting registers in an x86 seg-fault crash.

The first, EIP, specifies the code address at which the exception occurred. In RichQ's answer, he uses addr2line to show the source line that corresponds to the crash address. But EIP can be invalid; if you call a function pointer that is null, it can be 0x00000000, and if you corrupt your call stack, the return can pop any random value into EIP.

The second, CR2, specifies the data address which caused the segmentation fault. In RichQ's example, he is setting up i as a null pointer, then accessing it. In this case, CR2 would be 0x00000000. But if you change:

int j = *i

to:

int j = i[2];

Then you are trying to access address 0x00000008, and that's what would be found in CR2.

Martin Del Vecchio
Note that CR2 is actually the linear address of the faulting access, while 0x00000008 is the virtual offset. If the segment base is non-zero, the two will be different, and CR2 will report *segment_base+0x00000008*.
Nathan Fellman
A: 

Nathan, under what circumstances in a segment base non-zero? I've never seen that occur in my 5 years of Linux application development.

Thanks.

Martin Del Vecchio
A: 

@Martin

I do architectural validation for x86, so I'm very familiar with the architecture the processor provides, but very unfamiliar with how it's used. That's what I based my comment on. If CR2 can be counted on to give the correct answer, then I stand corrected.

Nathan Fellman
A: 

Nathan, I wasn't insisting that you were incorrect; I was just saying that in my (limited) experience with Linux, the segment base is always zero. Maybe that's a good question for me to ask...

Martin Del Vecchio