xyzt
xyzt

Reputation: 1311

How to interpret linux kernel trap error line?

I have a socket application written in C++ which runs on Linux. It crashed this morning and when I check the /var/log/messages I see the following line at the time of the crash:

kernel: traps: LogProcessor[9364] general protection ip:4f2555 sp:7fbd529b1670 error:0 in MyPrg[400000+21a000]

I want to dig into the code and find the reason but I don't know how to interpret the values in the error line.
Does it mean the error is caused by LogProcessor? What are the values "ip", "sp", "error:0", MyPrg[400000+21a000] ?

Upvotes: 6

Views: 17815

Answers (2)

Nabuchodonozor
Nabuchodonozor

Reputation: 736

The most meaningful information is Instruction Pointer (IP). You can examine your binary with GNU tools and check what happened. For example with addr2line

addr2line -e <your binary> 0x4f2555 

If your application was build with debug symbols (-g) and if fault happened in your code (not library), output should show you the problem.

SP is Stack Pointer at the time of the crash. MyPrg[400000+21a000] tells you Virtual Address of binary.

error:0 means dividing by zero (if your application works on x86 architecture): https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/include/asm/traps.h?id=d244d0e195bc12964bcf3b8eef45e715a7f203b0#n134

enum {
    X86_TRAP_DE = 0,    /*  0, Divide-by-zero */

Upvotes: 5

Tarek Dakhran
Tarek Dakhran

Reputation: 2161

This is General Protection Fault. There are multiple reasons that can cause it. You can read more in the aforementioned link.

  • LogProcessor[9364] - thread name and pid
  • ip:4f2555 - instruction pointer (looks suspicious here)
  • sp:7fbd529b1670 - stack pointer
  • error:0 - error code (why 0?)
  • MyPrg[400000+21a000] - program name

Upvotes: 5

Related Questions