How do you read a segfault kernel log message

前端 未结 3 1690
野趣味
野趣味 2020-12-12 10:16

This can be a very simple question, I\'m am attempting to debug an application which generates the following segfault error in the kern.log

kernel

3条回答
  •  难免孤独
    2020-12-12 10:42

    Based on my limited knowledge, your assumptions are correct.

    • sp = stack pointer
    • ip = instruction pointer
    • myapp[8048000+24000] = address

    If I were debugging the problem I would modify the code to produce a core dump or log a stack backtrace on the crash. You might also run the program under (or attach) GDB.

    The error code is just the architectural error code for page faults and seems to be architecture specific. They are often documented in arch/*/mm/fault.c in the kernel source. My copy of Linux/arch/i386/mm/fault.c has the following definition for error_code:

    • bit 0 == 0 means no page found, 1 means protection fault
    • bit 1 == 0 means read, 1 means write
    • bit 2 == 0 means kernel, 1 means user-mode

    My copy of Linux/arch/x86_64/mm/fault.c adds the following:

    • bit 3 == 1 means fault was an instruction fetch

提交回复
热议问题