Once again, another access violation

Posted by Zeno on Mon 24 May 2004 07:05 PM — 6 posts, 18,439 views.

USA #0

#0  0x080c22fa in violence_update () at fight.c:373
373                         ch->desc->character->desc = ch->desc;
(gdb) bt
#0  0x080c22fa in violence_update () at fight.c:373
#1  0x0812c468 in update_handler () at update.c:2023
#2  0x080a9cba in game_loop () at comm.c:690
#3  0x080a95b1 in main (argc=2, argv=0xbffff5d0) at comm.c:304
#4  0x42015967 in __libc_start_main () from /lib/i686/libc.so.6
(gdb) print ch
$1 = (struct char_data *) 0x8349ef0
(gdb) print ch->name
$2 = 0x834fb20 "Arion"
(gdb) print ch->desc
$3 = (struct descriptor_data *) 0x836a390
(gdb) print ch->desc->port
$4 = 4839
(gdb) ch->desc->character->desc
Undefined command: "ch-".  Try "help".
(gdb) print ch->desc->character->desc
Cannot access memory at address 0x4c
(gdb)


I don't get that at all. How can the char->desc be null but not ch->desc?

I had a post about something like this here:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4134

Is this related to that?
USA #1
You left one out :) What's at ch->desc->character?

My bet is that ch->desc->character doesn't actually point back to ch, and either the memory got corrupted (very evil) or somewhere the pointers didn't get set correctly (only slightly less evil).
USA #2

(gdb) print ch->desc->character
$1 = (struct char_data *) 0x0


Yeah, null. (I think, heh)
Should I add an ifcheck for null, or... is this just a common problem?
Canada #3
You can add the check for null here to correct this issue, but it leaves a larger one of where ch->desc->character is not being set. Is this perhaps while switched, possessed, something like that?
USA #4
Yes, like he said, you could fix it here but it'd be worth your time to figure out where it got broken in the first place. Did you change anything that would affect this kind of stuff? Switch, possess, snoop, anything?
USA #5
Switch is disabled. Possess isn't in. Snoop is stock code. *shrug* I'll add an ifcheck for now, and look around it.