How to read a segfault error message?

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

How to read a segfault error message?

Postposted on Thu May 08, 2014 2:12 pm

So I installed rtorrent via Homebrew, and I started it. It gave me this:
Code: Select all
ayanami:~ shinichi$ rtorrent
Caught Segmentation fault, dumping stack:
0   rtorrent                            0x000000010bbf97ee _Z8do_panici + 233
1   rtorrent                            0x000000010bc3a655 _ZN13SignalHandler6caughtEi + 63
2   libsystem_platform.dylib            0x00007fff91af15aa _sigtramp + 26
3   ???                                 0x00007fff683b14c0 0x0 + 140734942090432
4   rtorrent                            0x000000010bc3b2a0 _ZN12ThreadWorkerC1Ev + 14
5   rtorrent                            0x000000010bbf6534 main + 852
6   libdyld.dylib                       0x00007fff921a35fd start + 1
Abort trap: 6

How would I go about making sense of this?
Mothership: Thuban 1055T@3.7GHz, 12GB DDR3, M5A99X EVO, GTX470+Icy Vision Rev.2@840/3800, Vertex 2E 60GB
Supply ship: Sargas@2.8GHz, 12GB DDR3, M4A88TD-V EVO/USB3
Corsair: Macbook Air Ivy Bridge
Crayon Shin Chan
Minister of Gerbil Affairs
 
Posts: 2246
Joined: Fri Sep 06, 2002 11:14 am
Location: Malaysia

Re: How to read a segfault error message?

Postposted on Thu May 08, 2014 2:53 pm

This is the C call stack. Columns are:
Stack frame, file, location in memory(virtual address not physical), symbol at that address.

start() calls main() and at 852 instructions in to main() it called _ZN12ThreadWorkerC1Ev(). This looks to me like a mangled name, maybe from C++, that function then called what looks like a garbage location and crashed.

1) You need to demangle the names. I'm a C coder, been too many years since I did C++ to be able to demangle that.

2) You need to look at the source code for whatever that function is and work out what is going on. If you can rebuild with debug on it will help. Also if you can get the core dump and load it in a debugger it should point you right at the bad code.
notfred
Grand Gerbil Poohbah
 
Posts: 3748
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Re: How to read a segfault error message?

Postposted on Thu May 08, 2014 4:00 pm

http://demangler.com/ This site is amazing!

So the number at the end of the line shows how many instructions the CPU carried out before it had to jump to the above line on the stack? How would that ever be useful? Line numbers would be much better.

It looks like this is an old bug though. Apparently GCC 4.9 will produce a working binary.
Mothership: Thuban 1055T@3.7GHz, 12GB DDR3, M5A99X EVO, GTX470+Icy Vision Rev.2@840/3800, Vertex 2E 60GB
Supply ship: Sargas@2.8GHz, 12GB DDR3, M4A88TD-V EVO/USB3
Corsair: Macbook Air Ivy Bridge
Crayon Shin Chan
Minister of Gerbil Affairs
 
Posts: 2246
Joined: Fri Sep 06, 2002 11:14 am
Location: Malaysia

Re: How to read a segfault error message?

Postposted on Thu May 08, 2014 4:27 pm

I always paste the entire thing, if it's not pages, into Google. It's amazing how well that can work. ;)
Fuji X-E1 Leica Elmar 135 4 XF60mm 2.4 Macro | Zeiss FE 35mm 2.8
http://carnagepro.com
"Everything ... they eat everything, and fear is their bacon bits."
PenGun
Gerbil Elite
 
Posts: 791
Joined: Fri Jun 18, 2004 1:48 pm
Location: BC Canada

Re: How to read a segfault error message?

Postposted on Thu May 08, 2014 5:49 pm

You lose all the line numbers when you compile the code, unless you build it with the debugging info, which takes up valuable bytes. And when it has been optimised, the lines can be reordered or removed completely. You don't always even get function names, just the address of the function in memory. If you build it with debugging info, you probably get the line of code, (or at least, enough information for your debugger to identify which line of code it is) instead of just a line number.

But the crash handler can count the number of instructions executed by examining the state of the stack, and it can tell where those functions reside it memory. It then has to work backward from there, with the debug database, and the tables of functions in shared libraries.
mboza
Gerbil Team Leader
 
Posts: 203
Joined: Fri Sep 15, 2006 6:52 am

Re: How to read a segfault error message?

Postposted on Fri May 09, 2014 7:37 am

Before now I've had to build something with debug on my desktop and then dump the file with objdump and cross reference with the core file from the field to determine what was going on.

Best way is to always build with debug symbols, then strip the symbols in to .sym files and ship the stripped binaries. That way you get the small stripped binary but can still load the core file in to the debugger and get full debug info.
notfred
Grand Gerbil Poohbah
 
Posts: 3748
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 1 guest