Linux: How to debug a SIGSEGV? How do I trace the error source?

后端 未结 2 1113
执念已碎
执念已碎 2021-02-08 10:04

My firefox started crashing since today. I haven\'t changed anything on the system or on firefox config.

I use
strace -ff -o dumpfile.txt firefox

相关标签:
2条回答
  • 2021-02-08 10:43

    You can startup firefox in debug mode with this: firefox -d gdb

    this will start firefox inside gdb.

    You can the issue the gdb command 'run' and get a traceback when firefox crashes. This may be difficult, as firefox ships with stripped libraries which only shows which library and offset the code is in, not the function names.

    Another alternative is to start firefox in safemode: firefox -safe-mode and turn off any plugins you may have installed until it doesn't crash anymore.

    The last alternative is to enable the developer mode of firefox, and allow it to send the firefox crash session to the mozilla server. Then you can go the to mozilla site and see the detailed traceback of your failed firefox session.

    0 讨论(0)
  • 2021-02-08 10:44

    Ivan, your real question is "how do I debug a SIGSEGV?"

    strace is rarely a good help here. SIGSEGV means that the application tried to dereference (access) a location in memory which which hasn't been allocated (or not allowed to be dereferenced for various other reasons). Chances are high that it is not related to the system calls activity which strace is capturing. In order to discover the cause of your crash, start by understanding what address is being dereferenced and what function tries to do that. Debugger is the right tool for this task.

    Here's what you need to do:

     gdb <your_app_name> <your_coredump_file>
    

    in there, analyzing the last executed instruction and using "info registers" you'll see the address in question. Using the "bt" command you'll see the callstack. By walking the callstack up, you'll discover how the incorrect address is being calculated. One of the steps involved in this address calculation is the cause of your problem.

    Debugging is fun and this is a good opportunity to delve into it. A good book or some online articles can help you there. Google away and good luck!

    0 讨论(0)
提交回复
热议问题