[crossfire] MF Crash/Arena petmode

Mark Wedel mwedel at sonic.net
Wed Jul 27 01:31:35 CDT 2005


Alex Schultz wrote:
>
     
      Hi,
     
     >
     
     
     >
     
      It seems something went wrong with the arena petmode and it caused two 
     
     >
     
      crashes on metalforge today, and it crashed right in the middle of one 
     
     >
     
      of the code blocks that's used in the arena petmode, but I can't figure 
     
     >
     
      out what's wrong despite writing most of this code block myself (giant 
     
     >
     
      expression beginning on line 118 of pets.c). In case anyone can help, 
     
     >
     
      I've attached the core dump files I got from Leaf, and here's the 
     
     >
     
      offending expression for quick reference.
     
     
  I'd personally suggest cleaning that 'if' statement at all possible - break it 
into smaller pieces or something.

  Anyways, hard to know exactly the logic of the if statement.  But looking at 
the core files, and at the statements, that big problem I see is that you are 
looking at owner->contr->... without knowing in fact that owner->contr is in 
fact valid.

  owner does not have to be a player, and looking at the two crashes, in fact, 
owner is not a player, but a Balrog.  I'd also be wary of any other ->contr 
checks here, unless you really know 100% sure that they are valid.  The if 
statement is too complex for me to see that at a glance if the checks are there.

  The other problem with such complex if statements is that the crash point is 
really 'someplace' in that statement - breaking it in smaller pieces gives you a 
bit finer control.

  The cleanest thing is if you can do some basic checks like:

  if (simpler expression) continue;
  if (other simpler expression) continue;
  ...

  and then perhaps the if statement that is executed could perhaps be readable.


>
     
     
     >
     
      pets.c, line 118  and onward:
     
     >
     
             if (QUERY_FLAG(tmp2,FLAG_ALIVE) && (
     
     >
     
                 !QUERY_FLAG(tmp2, FLAG_FRIENDLY) || (
     
     >
     
                     (owner != tmp2->owner) &&
     
     >
     
                     op_on_battleground(pet, NULL, NULL) &&
     
     >
     
                     op_on_battleground(owner, NULL, NULL) &&
     
     >
     
                     op_on_battleground(tmp2, NULL, NULL) &&
     
     >
     
                     (owner->contr->petmode == pet_arena) && !(
     
     >
     
                         (tmp2->owner->contr->party_number ==
     
     >
     
                             owner->contr->party_number) &&
     
     >
     
                         (owner->contr->party_number > 0))))
     
     >
     
                 && !QUERY_FLAG(tmp2,FLAG_UNAGGRESSIVE) &&
     
     >
     
                 tmp2 != pet && tmp2 != owner && (
     
     >
     
                     (tmp2->type != PLAYER) || (
     
     >
     
                     op_on_battleground(pet, NULL, NULL) &&
     
     >
     
                     op_on_battleground(owner, NULL, NULL) &&
     
     >
     
                     op_on_battleground(tmp2, NULL, NULL) &&
     
     >
     
                     (owner->contr->petmode == pet_arena) && !(
     
     >
     
                         (tmp2->contr->party_number ==
     
     >
     
                             owner->contr->party_number) &&
     
     >
     
                         (owner->contr->party_number > 0)))) &&
     
     >
     
                 can_detect_enemy(pet, tmp2, rv)) {
     
     >
     
     
     >
     
         Thanks,
     
     >
     
            Alex Schultz
     
     >
     
     
     >
     
     
     >
     
      ------------------------------------------------------------------------
     
     >
     
     
     >
     
      Core was generated by `/home/crossfire/bin/crossfire -d'.
     
     >
     
      Program terminated with signal 6, Aborted.
     
     >
     
      #0 0x400e6921 in kill () from /lib/libc.so.6
     
     >
     
     
     >
     
      (gdb) Executing command "bt full":
     
     >
     
     
     >
     
      #0 0x400e6921 in kill () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
      #1 0x400e6720 in raise () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
      #2 0x400e7808 in abort () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
      #3 0x08086144 in fatal_signal (make_core=1, close_sockets=1) at init.c:957
     
     >
     
      No locals.
     
     >
     
      #4 0x08085fe0 in rec_sigsegv (i=11) at init.c:898
     
     >
     
      No locals.
     
     >
     
      #5 <signal handler called>
     
     >
     
      No symbol table info available.
     
     >
     
      #6 0x08091479 in get_pet_enemy (pet=0xaa18980, rv=0xbffff4b0) at pets.c:118
     
     >
     
      tmp2 = (struct obj *) 0x8
     
     >
     
      owner = (struct obj *) 0x8117f69
     
     >
     
      tmp = (struct obj *) 0xbffff538
     
     >
     
      attacker = (struct obj *) 0xbffff4b0
     
     >
     
      tmp3 = (struct obj *) 0xaa18980
     
     >
     
      i = 134790287
     
     >
     
      x = -16385
     
     >
     
      y = -3096
     
     >
     
      nm = (struct mapdef *) 0x401d3458
     
     >
     
      search_arr = {5, 15, 23, 21, 14, 9, 20, 22, 11, 17, 13, 19, 10, 12,
     
     >
     
      16, 18, 24, 26, 40, 31, 37, 44, 35, 41, 36, 34, 43, 32, 39, 48, 28, 47, 42,
     
     >
     
      38, 25, 46, 45, 29, 27, 30, 33, 1075655768, 1075655768, 135358108, 24,
     
     >
     
      139796480, 1114131, 0, 0}
     
     >
     
      #7 0x0808bc8f in find_enemy (npc=0xaa18980, rv=0xbffff4b0) at monster.c:211
     
     >
     
      attacker = (struct obj *) 0x0
     
     >
     
      tmp = (struct obj *) 0x0
     
     >
     
      #8 0x0808c0ab in move_monster (op=0xaa18980) at monster.c:326
     
     >
     
      dir = 0
     
     >
     
      diff = 0
     
     >
     
      owner = (struct obj *) 0x0
     
     >
     
      enemy = (struct obj *) 0x8c16890
     
     >
     
      part = (struct obj *) 0x80b82bf
     
     >
     
      oph = (struct obj *) 0xaa18980
     
     >
     
      rv = {distance = 0, distance_x = 0, distance_y = 0, direction = 0,
     
     >
     
      part = 0x0}
     
     >
     
      #9 0x080bc532 in process_object (op=0xaa18980) at time.c:1312
     
     >
     
      evt = (struct _event *) 0x0
     
     >
     
      #10 0x0808af52 in process_events (map=0x0) at main.c:1002
     
     >
     
      op = (struct obj *) 0xaa18980
     
     >
     
      marker = {contr = 0x0, next = 0x0, prev = 0x0,
     
     >
     
      active_next = 0xaa1ddf4, active_prev = 0xaa18980, below = 0x0, above = 0x0,
     
     >
     
      inv = 0x0, container = 0x0, env = 0x0, more = 0x0, head = 0x0, map = 0x0,
     
     >
     
      count = 0, refcount = 0, name = 0x0, name_pl = 0x0, title = 0x0, race = 0x0,
     
     >
     
      slaying = 0x0, skill = 0x0, msg = 0x0, lore = 0x0, x = 0, y = 0, ox = 0,
     
     >
     
      oy = 0, speed = 0, speed_left = 0, nrof = 0, face = 0x0, direction = 0 '\0',
     
     >
     
      facing = 0 '\0', type = 0 '\0', subtype = 0 '\0', client_type = 0, resist = {
     
     >
     
      0 <repeats 26 times>}, attacktype = 0, path_attuned = 0,
     
     >
     
      path_repelled = 0, path_denied = 0, material = 0, materialname = 0x0,
     
     >
     
      magic = 0 '\0', state = 0 '\0', value = 0, level = 0, last_heal = 0,
     
     >
     
      last_sp = 0, last_grace = 0, last_eat = 0, invisible = 0, pick_up = 0 '\0',
     
     >
     
      item_power = 0 '\0', gen_sp_armour = 0 '\0', weight = 0, weight_limit = 0,
     
     >
     
      carrying = 0, glow_radius = 0 '\0', stats = {Str = 0 '\0', Dex = 0 '\0',
     
     >
     
      Con = 0 '\0', Wis = 0 '\0', Cha = 0 '\0', Int = 0 '\0', Pow = 0 '\0',
     
     >
     
      wc = 0 '\0', ac = 0 '\0', hp = 0, maxhp = 0, sp = 0, maxsp = 0, grace = 0,
     
     >
     
      maxgrace = 0, exp = 0, food = 0, dam = 0, luck = 0 '\0'}, perm_exp = 0,
     
     >
     
      current_weapon_script = 0x0, current_weapon = 0x0, weapontype = 0,
     
     >
     
      tooltype = 0, body_info = '\0' <repeats 11 times>,
     
     >
     
      body_used = '\0' <repeats 11 times>, owner = 0x0, ownercount = 0,
     
     >
     
      enemy = 0x0, attacked_by = 0x0, attacked_by_count = 0, randomitems = 0x0,
     
     >
     
      run_away = 0, chosen_skill = 0x0, hide = 0, move_status = 0, move_type = 0,
     
     >
     
      will_apply = 0 '\0', spellitem = 0x0, expmul = 0, duration = 0,
     
     >
     
      duration_modifier = 0 '\0', casting_time = 0, spell = 0x0,
     
     >
     
      start_holding = 0, spellarg = 0x0, dam_modifier = 0 '\0', range = 0 '\0',
     
     >
     
      range_modifier = 0 '\0', arch = 0x0, other_arch = 0x0, flags = {0, 0, 0, 0},
     
     >
     
      animation_id = 0, anim_speed = 0 '\0', last_anim = 0 '\0', elevation = 0,
     
     >
     
      smoothlevel = 0 '\0', events = 0x0, custom_name = 0x0}
     
     >
     
      tag = 3461004
     
     >
     
      #11 0x0808b61d in main (argc=2, argv=0xbffff8d4) at main.c:1232
     
     >
     
      evtid = 14
     
     >
     
      CFP = {Type = {-1073743744, 1073808556, 1045, 1073809048, -1073743808,
     
     >
     
      1073777557, 1073809460, 1074133536, 1, 0, 1074961282, 1075655768,
     
     >
     
      1075655756, -1073743836, 1074615257}, Value = {0xbffff86c, 0xbffff8e0,
     
     >
     
      0x81506f8, 0xe9, 0x401b306b, 0x401d3458, 0x40010020, 0xbffff858,
     
     >
     
      0x401b346c, 0x81505b4, 0x81508ec, 0x0, 0x0, 0x8059008, 0x401d3458}}
     
     >
     
      #12 0x400d553d in __libc_start_main () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
     
     >
     
      (gdb) Executing command "up" (20 times):
     
     >
     
     
     >
     
      #1 0x400e6720 in raise () from /lib/libc.so.6
     
     >
     
      #2 0x400e7808 in abort () from /lib/libc.so.6
     
     >
     
      #3 0x08086144 in fatal_signal (make_core=1, close_sockets=1) at init.c:957
     
     >
     
      957 abort();
     
     >
     
      #4 0x08085fe0 in rec_sigsegv (i=11) at init.c:898
     
     >
     
      898 fatal_signal(1, 1);
     
     >
     
      #5 <signal handler called>
     
     >
     
      #6 0x08091479 in get_pet_enemy (pet=0xaa18980, rv=0xbffff4b0) at pets.c:118
     
     >
     
      118 if (QUERY_FLAG(tmp2,FLAG_ALIVE) && (
     
     >
     
      #7 0x0808bc8f in find_enemy (npc=0xaa18980, rv=0xbffff4b0) at monster.c:211
     
     >
     
      211 tmp= get_pet_enemy(npc,rv);
     
     >
     
      #8 0x0808c0ab in move_monster (op=0xaa18980) at monster.c:326
     
     >
     
      326 else if((enemy= find_enemy(op, &rv)))
     
     >
     
      #9 0x080bc532 in process_object (op=0xaa18980) at time.c:1312
     
     >
     
      1312 if(move_monster(op) || QUERY_FLAG(op, FLAG_FREED))
     
     >
     
      #10 0x0808af52 in process_events (map=0x0) at main.c:1002
     
     >
     
      1002 process_object (op);
     
     >
     
      #11 0x0808b61d in main (argc=2, argv=0xbffff8d4) at main.c:1232
     
     >
     
      1232 process_events(NULL); /* "do" something with objects with speed */
     
     >
     
      #12 0x400d553d in __libc_start_main () from /lib/libc.so.6
     
     >
     
     
     >
     
     
     >
     
      ------------------------------------------------------------------------
     
     >
     
     
     >
     
      Core was generated by `/home/crossfire/bin/crossfire -d'.
     
     >
     
      Program terminated with signal 6, Aborted.
     
     >
     
      #0 0x400e6921 in kill () from /lib/libc.so.6
     
     >
     
     
     >
     
      (gdb) Executing command "bt full":
     
     >
     
     
     >
     
      #0 0x400e6921 in kill () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
      #1 0x400e6720 in raise () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
      #2 0x400e7808 in abort () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
      #3 0x08086144 in fatal_signal (make_core=1, close_sockets=1) at init.c:957
     
     >
     
      No locals.
     
     >
     
      #4 0x08085fe0 in rec_sigsegv (i=11) at init.c:898
     
     >
     
      No locals.
     
     >
     
      #5 <signal handler called>
     
     >
     
      No symbol table info available.
     
     >
     
      #6 0x08091479 in get_pet_enemy (pet=0x968a3f0, rv=0xbfffd7b0) at pets.c:118
     
     >
     
      tmp2 = (struct obj *) 0x7
     
     >
     
      owner = (struct obj *) 0x0
     
     >
     
      tmp = (struct obj *) 0x0
     
     >
     
      attacker = (struct obj *) 0xbfffd7b0
     
     >
     
      tmp3 = (struct obj *) 0x968a3f0
     
     >
     
      i = 134790287
     
     >
     
      x = -16385
     
     >
     
      y = -10520
     
     >
     
      nm = (struct mapdef *) 0x401d3458
     
     >
     
      search_arr = {4, 23, 24, 9, 16, 20, 10, 13, 19, 18, 14, 21, 11, 12,
     
     >
     
      22, 15, 17, 39, 34, 36, 30, 35, 41, 26, 40, 25, 37, 32, 27, 44, 38, 33, 28,
     
     >
     
      29, 45, 46, 47, 43, 48, 31, 42, 0, 0, 0, 0, 151674880, 1114127, 0, 0}
     
     >
     
      #7 0x0808bc8f in find_enemy (npc=0x968a3f0, rv=0xbfffd7b0) at monster.c:211
     
     >
     
      attacker = (struct obj *) 0x0
     
     >
     
      tmp = (struct obj *) 0x0
     
     >
     
      #8 0x0808c0ab in move_monster (op=0x968a3f0) at monster.c:326
     
     >
     
      dir = 0
     
     >
     
      diff = 0
     
     >
     
      owner = (struct obj *) 0x0
     
     >
     
      enemy = (struct obj *) 0x968a5bc
     
     >
     
      part = (struct obj *) 0x80b82bf
     
     >
     
      oph = (struct obj *) 0x968a3f0
     
     >
     
      rv = {distance = 0, distance_x = 0, distance_y = 0, direction = 0,
     
     >
     
      part = 0x0}
     
     >
     
      #9 0x080bc532 in process_object (op=0x968a3f0) at time.c:1312
     
     >
     
      evt = (struct _event *) 0x0
     
     >
     
      #10 0x0808af52 in process_events (map=0x0) at main.c:1002
     
     >
     
      op = (struct obj *) 0x968a3f0
     
     >
     
      marker = {contr = 0x0, next = 0x0, prev = 0x0,
     
     >
     
      active_next = 0x8cad80c, active_prev = 0x968a3f0, below = 0x0, above = 0x0,
     
     >
     
      inv = 0x0, container = 0x0, env = 0x0, more = 0x0, head = 0x0, map = 0x0,
     
     >
     
      count = 0, refcount = 0, name = 0x0, name_pl = 0x0, title = 0x0, race = 0x0,
     
     >
     
      slaying = 0x0, skill = 0x0, msg = 0x0, lore = 0x0, x = 0, y = 0, ox = 0,
     
     >
     
      oy = 0, speed = 0, speed_left = 0, nrof = 0, face = 0x0, direction = 0 '\0',
     
     >
     
      facing = 0 '\0', type = 0 '\0', subtype = 0 '\0', client_type = 0, resist = {
     
     >
     
      0 <repeats 26 times>}, attacktype = 0, path_attuned = 0,
     
     >
     
      path_repelled = 0, path_denied = 0, material = 0, materialname = 0x0,
     
     >
     
      magic = 0 '\0', state = 0 '\0', value = 0, level = 0, last_heal = 0,
     
     >
     
      last_sp = 0, last_grace = 0, last_eat = 0, invisible = 0, pick_up = 0 '\0',
     
     >
     
      item_power = 0 '\0', gen_sp_armour = 0 '\0', weight = 0, weight_limit = 0,
     
     >
     
      carrying = 0, glow_radius = 0 '\0', stats = {Str = 0 '\0', Dex = 0 '\0',
     
     >
     
      Con = 0 '\0', Wis = 0 '\0', Cha = 0 '\0', Int = 0 '\0', Pow = 0 '\0',
     
     >
     
      wc = 0 '\0', ac = 0 '\0', hp = 0, maxhp = 0, sp = 0, maxsp = 0, grace = 0,
     
     >
     
      maxgrace = 0, exp = 0, food = 0, dam = 0, luck = 0 '\0'}, perm_exp = 0,
     
     >
     
      current_weapon_script = 0x0, current_weapon = 0x0, weapontype = 0,
     
     >
     
      tooltype = 0, body_info = '\0' <repeats 11 times>,
     
     >
     
      body_used = '\0' <repeats 11 times>, owner = 0x0, ownercount = 0,
     
     >
     
      enemy = 0x0, attacked_by = 0x0, attacked_by_count = 0, randomitems = 0x0,
     
     >
     
      run_away = 0, chosen_skill = 0x0, hide = 0, move_status = 0, move_type = 0,
     
     >
     
      will_apply = 0 '\0', spellitem = 0x0, expmul = 0, duration = 0,
     
     >
     
      duration_modifier = 0 '\0', casting_time = 0, spell = 0x0,
     
     >
     
      start_holding = 0, spellarg = 0x0, dam_modifier = 0 '\0', range = 0 '\0',
     
     >
     
      range_modifier = 0 '\0', arch = 0x0, other_arch = 0x0, flags = {0, 0, 0, 0},
     
     >
     
      animation_id = 0, anim_speed = 0 '\0', last_anim = 0 '\0', elevation = 0,
     
     >
     
      smoothlevel = 0 '\0', events = 0x0, custom_name = 0x0}
     
     >
     
      tag = 154671
     
     >
     
      #11 0x0808b61d in main (argc=2, argv=0xbfffdbd4) at main.c:1232
     
     >
     
      evtid = 14
     
     >
     
      CFP = {Type = {-1073751168, 1073808556, 1045, 1073809048, -1073751232,
     
     >
     
      1073777557, 1073809460, 1074133536, 1, 0, 1074961282, 1075655768,
     
     >
     
      1075655756, -1073751260, 1074615257}, Value = {0xbfffdb6c, 0xbfffdbe0,
     
     >
     
      0x81506f8, 0xe9, 0x401b306b, 0x401d3458, 0x40010020, 0xbfffdb58,
     
     >
     
      0x401b346c, 0x81505b4, 0x81508ec, 0x0, 0x0, 0x8059008, 0x401d3458}}
     
     >
     
      #12 0x400d553d in __libc_start_main () from /lib/libc.so.6
     
     >
     
      No symbol table info available.
     
     >
     
     
     >
     
      (gdb) Executing command "up" (20 times):
     
     >
     
     
     >
     
      #1 0x400e6720 in raise () from /lib/libc.so.6
     
     >
     
      #2 0x400e7808 in abort () from /lib/libc.so.6
     
     >
     
      #3 0x08086144 in fatal_signal (make_core=1, close_sockets=1) at init.c:957
     
     >
     
      957 abort();
     
     >
     
      #4 0x08085fe0 in rec_sigsegv (i=11) at init.c:898
     
     >
     
      898 fatal_signal(1, 1);
     
     >
     
      #5 <signal handler called>
     
     >
     
      #6 0x08091479 in get_pet_enemy (pet=0x968a3f0, rv=0xbfffd7b0) at pets.c:118
     
     >
     
      118 if (QUERY_FLAG(tmp2,FLAG_ALIVE) && (
     
     >
     
      #7 0x0808bc8f in find_enemy (npc=0x968a3f0, rv=0xbfffd7b0) at monster.c:211
     
     >
     
      211 tmp= get_pet_enemy(npc,rv);
     
     >
     
      #8 0x0808c0ab in move_monster (op=0x968a3f0) at monster.c:326
     
     >
     
      326 else if((enemy= find_enemy(op, &rv)))
     
     >
     
      #9 0x080bc532 in process_object (op=0x968a3f0) at time.c:1312
     
     >
     
      1312 if(move_monster(op) || QUERY_FLAG(op, FLAG_FREED))
     
     >
     
      #10 0x0808af52 in process_events (map=0x0) at main.c:1002
     
     >
     
      1002 process_object (op);
     
     >
     
      #11 0x0808b61d in main (argc=2, argv=0xbfffdbd4) at main.c:1232
     
     >
     
      1232 process_events(NULL); /* "do" something with objects with speed */
     
     >
     
      #12 0x400d553d in __libc_start_main () from /lib/libc.so.6
     
     >
     
     
     >
     
     
     >
     
      ------------------------------------------------------------------------
     
     >
     
     
     >
     
      _______________________________________________
     
     >
     
      crossfire mailing list
     
     >
     
     
      crossfire at metalforge.org
      
      
     >
     
     
      http://mailman.metalforge.org/mailman/listinfo/crossfire
      
      
     
    


More information about the crossfire mailing list