Go Back   Angband Forums > Angband > ToME

Thread Tools Display Modes
Old October 18, 2010, 05:29   #1
Therem Harth
Therem Harth's Avatar
Join Date: Jan 2008
Posts: 889
Therem Harth is on a distinguished road
'nother TFork segfault

This time on making a wish for something that doesn't exist in the game. Which is weird because I haven't messed with the wish code at all.

Basically if you wish for "foo" or some other thing that isn't an item or a monster, the game will spit out a Lua error about doing get_stick_charges on a nil value, followed by a crash. The backtrace looks like this:

#0  object_desc_str (t=0xbffff054 "", s=0x0) at object1.c:1262
#1  0x0810c54e in object_desc (buf=0xbffff178 "wand of poison blood", 
    o_ptr=0xbffff2b0, pref=0, mode=0) at object1.c:2059
#2  0x08136a2a in test_object_wish (name=0xbffff330 "foo", o_ptr=0xbffff2b0, 
    forge=0xbffff2b0, what=0x81ea03f "wish") at xtra2.c:7411
#3  0x08136dde in make_wish () at xtra2.c:7570
#4  0x081c04aa in do_cmd_debug () at wizard2.c:1912
#5  0x080ec59e in process_command () at dungeon.c:3558
#6  0x080f159e in process_player () at dungeon.c:4875
#7  0x080f2296 in dungeon (new_game=<value optimized out>) at dungeon.c:5327
#8  play_game (new_game=<value optimized out>) at dungeon.c:5816
#9  0x081dea5c in main (argc=1, argv=<value optimized out>) at main.c:908
I did try doing a check for NULL before object1.c line 1262... That prevents the crash, but I still get an unsightly Lua error, which I'm guessing indicates that that wasn't the actual bug.

(Any help would be appreciated, I'm terribly lame with dealing with strings in C.)

Edit: and yeah I realize it's probably a bad sign when altering one part of a codebase causes a completely unrelated part to throw an error.
Therem Harth is offline   Reply With Quote
Old October 23, 2010, 03:58   #2
Pete Mack
Join Date: Apr 2007
Location: Seattle, WA
Posts: 4,596
Donated: $40
Pete Mack is on a distinguished road
You are out of luck if you don't have a real debugger.
You should be running your app from within the debugger, always.
If you are not on Windows, use GDB. (I've had terrible luck with GDB on Windows.)
If you are on Windows, download Visual Studio Express if you have enough memory. (Visual Studio is a notorious memory hog.) You will have to set up a project, which takes a couple hours. But having a debugger with break points makes it so worth it.
Pete Mack is offline   Reply With Quote
Old October 23, 2010, 07:07   #3
AnonymousHero's Avatar
Join Date: Jun 2007
Posts: 1,342
AnonymousHero is on a distinguished road
If you need a debugger for a unix-like system, you can also use DDD. It's a graphical front-end for GDB. It's been ages since I actually used it, but I remember it as being excellent (at the time).
AnonymousHero is offline   Reply With Quote
Old October 23, 2010, 07:56   #4
Join Date: Apr 2007
Posts: 441
Atarlost is on a distinguished road
If the error is in Lua a debugger won't help much*. You'll need to resort to gratuitous print statement debugging.

* until you get your next error and it's in the C.
One Ring to rule them all. One Ring to bind them.
One Ring to bring them all and in the darkness interrupt the movie.
Atarlost is offline   Reply With Quote
Old October 23, 2010, 15:26   #5
Therem Harth
Therem Harth's Avatar
Join Date: Jan 2008
Posts: 889
Therem Harth is on a distinguished road
I was using GDB... What I posted was GDB's backtrace.

For the record, the problem turned out to be a pretty weird one - some schools cannot have their spells altered in any way, otherwise the game will crash. Air school is one of those schools, and I'd made modifications to it.

I'm still trying to figure out why this is; I would guess some of Air's attributes are hard-coded in a way not conducive to just changing the Lua code. I tried removing some of the wands for that school, but that didn't work at all... But anyway it's fixed now in Git, though I'm not happy with Air school still being mostly useless.
Therem Harth is offline   Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
TFork on Gitorious Therem Harth ToME 4 October 20, 2010 20:26
Announcing TFork Therem Harth ToME 31 September 19, 2010 04:23
TFork 0.2 Therem Harth Variants 7 July 6, 2010 17:54
TFork 0.1 Therem Harth Variants 1 July 3, 2010 16:54
Angband SegFault under FreeBSD AronaDaal Vanilla 17 January 2, 2008 20:39

All times are GMT +1. The time now is 21:53.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.