Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ get_obj_type, loop

get_obj_type, loop

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zeno   USA  (2,871 posts)  Bio
Date Wed 22 Sep 2004 07:28 PM (UTC)
Message
Something I want to avoid is the MUD being caught in a loop, and until now, I've succeeded. But just today, it was caught in a loop when I got home from Cisco.

0x080bc822 in get_obj_type (pObjIndex=0x82e19c8) at handler.c:2102
2102            if ( obj->pIndexData == pObjIndex )
(gdb) bt
#0  0x080bc822 in get_obj_type (pObjIndex=0x82e19c8) at handler.c:2102
#1  0x080f43ad in reset_area (pArea=0x82d8e98) at reset.c:1464
#2  0x080a6bd5 in area_update () at db.c:2517
#3  0x0811f051 in update_handler () at update.c:2189
#4  0x0809ba2b in game_loop () at comm.c:690
#5  0x0809b333 in main (argc=8, argv=0xbfffe650) at comm.c:304
#6  0x42015967 in __libc_start_main () from /lib/i686/libc.so.6

(gdb) list
2097    OBJ_DATA *get_obj_type( OBJ_INDEX_DATA *pObjIndex )
2098    {
2099        OBJ_DATA *obj;
2100
2101        for ( obj = last_object; obj; obj = obj->prev )
2102            if ( obj->pIndexData == pObjIndex )
2103                return obj;
2104
2105        return NULL;
2106    }


(gdb) f 1
#1  0x080f43ad in reset_area (pArea=0x82d8e98) at reset.c:1464
1464            if ( pArea->nplayer > 0 ||
(gdb) list
1459                    pReset->arg3 );
1460              bug( buf, 0 );
1461    */
1462              continue;
1463            }
1464            if ( pArea->nplayer > 0 ||
1465               !(to_obj = get_obj_type(pObjToIndex)) ||
1466                !to_obj->in_room ||
1467                 count_obj_list(pObjIndex, to_obj->first_content) > 0 )
1468            {

(gdb) p *obj
$1 = {next = 0x8357358, prev = 0x836f8b0, next_content = 0x8357358, prev_content = 0x836f8b0,
  first_content = 0x0, last_content = 0x0, in_obj = 0x0, carried_by = 0x0,
  first_extradesc = 0x0, last_extradesc = 0x0, first_affect = 0x0, last_affect = 0x0,
  pIndexData = 0x82b78f0, in_room = 0x82d6638, name = 0x82b7988 "blood",
  short_descr = 0x82b79a0 "the spilled blood",
  description = 0x82b79c0 "A pool of spilled blood lies here.", action_desc = 0x81c34b0 "",
  item_type = 27, mpscriptpos = 0, extra_flags = {bits = {0, 0, 0, 0}}, magic_flags = 0,
  wear_flags = 0, mpact = 0x0, mpactnum = 0, wear_loc = -1, weight = 1, cost = 0, level = 0,
  timer = 1, value = {5, 3, 0, 1, 0, 0}, count = 5, serial = 5594, room_vnum = 1023,
  ashards = 0}
(gdb) p *pObjIndex
$2 = {next = 0x0, next_sort = 0x0, first_extradesc = 0x0, last_extradesc = 0x0,
  first_affect = 0x0, last_affect = 0x0, mudprogs = 0x0, progtypes = {bits = {0, 0, 0, 0}},
  name = 0x82e1a60 "wooden chest", short_descr = 0x82e1a80 "a wooden chest",
  description = 0x82e1aa0 "A large wooden chest sits in the corner of the room.",
  action_desc = 0x81c34b0 "", vnum = 2613, level = 0, item_type = 15, extra_flags = {bits = {0,
      0, 0, 0}}, magic_flags = 0, wear_flags = 0, count = 1, weight = 1, cost = 0, value = {10,
    1, 2612, 0, 0, 0}, serial = 161, layers = 0, rent = 0, ashards = 0}


I can't print anymore, because I killed the loop. Any idea how this can be fixed?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Wed 22 Sep 2004 08:14 PM (UTC)
Message
2101        for ( obj = last_object; obj; obj = obj->prev )
2102            if ( obj->pIndexData == pObjIndex )
2103                return obj;

Well, that seems to be the culprit, but that would mean that your linked list has gotten corrupted. Either an object's prev points to itself, or there is some other form of loop in the linked list. I can't think of any other reason why that loop would go on forever.

Of course one wonders how your linked list would have gotten corrupted in the first place. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Wed 22 Sep 2004 08:24 PM (UTC)
Message
Well pObjIndex is a container. Would that matter? I have no idea why it would be corrupt.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Wed 22 Sep 2004 09:57 PM (UTC)
Message
pObjIndex doesn't have anything to do with it, if you look at the for loop it's stuck in it's just looping over the object linked list.

Are you sure it was looping in that for loop? It's the only loop in the code you showed, but... one never knows.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #4 on Wed 22 Sep 2004 11:31 PM (UTC)
Message
I'm positive it was. Any idea what would cause it to become corrupt?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #5 on Thu 23 Sep 2004 12:14 AM (UTC)
Message
Well, it would have to be some code change you made somewhere I think. Either that or e.g. you changed a structure's member ordering and didn't do a full recompile. It's kind of weird that it would happen so rarely, though.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,026 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.