You are not logged in.

#1 2010-06-20 13:43:41

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

What does one do about segmentation faults like these?

So I'm messing around with a rather old version of an Angband variant. The binary compiles fine; but on some actions the game immediately crashes. GDB gives me this during the crash:

Program received signal SIGSEGV, Segmentation fault.
0xb7d4ea6d in vfprintf () from /lib/libc.so.6

What is this? Is vfprintf deprecated or something? How can I find out more, and how can I edit the source to fix this?

Offline

#2 2010-06-20 19:46:39

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: What does one do about segmentation faults like these?

First of all, set the -g flag in the CFLAGS and LDFLAGS variable. This enables debug symbols and gives gdb the ability to use/print source files and line numbers instead of object offsets.
After the program crashed in gdb just use the backtrace command to see what function calls vfprintf and causes the segfault.
You could also use the print and examine commands to look where the pointer(s) given to vfprintf point to. I would assume that one of them hold an invalid memory address (maybe NULL).
Then look into the corresponding source code area (file and line number listed in backtrace) to see if you could fix it.

Offline

Board footer

Powered by FluxBB