Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in game::activity_on_finish when crafting clean water interrupted by zombie #10970

Closed
dholmes215 opened this issue Jan 23, 2015 · 4 comments · Fixed by #11179
Closed

Crash in game::activity_on_finish when crafting clean water interrupted by zombie #10970

dholmes215 opened this issue Jan 23, 2015 · 4 comments · Fixed by #11179
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes.
Milestone

Comments

@dholmes215
Copy link
Contributor

I was crafting clean water "as long as possible" when a zombie child interrupted me. I don't remember if I tried to continue or quit right there.

(gdb) bt
#0  0x000000010059c58d in game::activity_on_finish (this=0x6fffff90010) at src/game.cpp:1843
#1  0x000000010059b3b2 in game::process_activity (this=0x6fffff90010) at src/game.cpp:1585
#2  0x00000001005998de in game::do_turn (this=0x6fffff90010) at src/game.cpp:1419
#3  0x00000001009c276a in main (argc=0, argv=0x22ab38) at src/main.cpp:290
(gdb) l
1838            break;
1839        case ACT_LONGCRAFT:
1840            complete_craft();
1841            u.activity.type = ACT_NULL;
1842            {
1843                int batch_size = u.activity.values.front();
1844                if( making_would_work( u.lastrecipe, batch_size ) ) {
1845                    make_all_craft(u.lastrecipe, batch_size);
1846                }
1847            }
(gdb) print u.activity
$2 = {
  <JsonSerializer> = {
    _vptr.JsonSerializer = 0x100d11730 <vtable for player_activity+16>
  },
  <JsonDeserializer> = {
    _vptr.JsonDeserializer = 0x100d11760 <vtable for player_activity+64>
  },
  members of player_activity:
  type = ACT_NULL,
  moves_left = 0,
  index = -1,
  position = -2147483648,
  name = {
    static npos = <optimized out>,
    _M_dataplus = {
      <std::allocator<char>> = {
        <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
      members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
      _M_p = 0x3fefbfc38 <cygstdc++-6!_ZNSs4_Rep20_S_empty_rep_storageE+24> ""
    }
  },
  ignore_trivial = false,
  values = {
    <std::_Vector_base<int, std::allocator<int> >> = {
      _M_impl = {
        <std::allocator<int>> = {
          <__gnu_cxx::new_allocator<int>> = {<No data fields>}, <No data fields>},
        members of std::_Vector_base<int, std::allocator<int> >::_Vector_impl:
        _M_start = 0x0,
        _M_finish = 0x0,
        _M_end_of_storage = 0x0
      }
    }, <No data fields>},
  str_values = {
    <std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {
      _M_impl = {
        <std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {
          <__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>},
        members of std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >                                                            > >::_Vector_impl:
        _M_start = 0x0,
        _M_finish = 0x0,
        _M_end_of_storage = 0x0
      }
    }, <No data fields>},
  placement = {
    <JsonSerializer> = {
      _vptr.JsonSerializer = 0x100d128b0 <vtable for point+16>
    },
    <JsonDeserializer> = {
      _vptr.JsonDeserializer = 0x100d128e0 <vtable for point+64>
    },
    members of point:
    x = -1,
    y = -1
  },
  warned_of_proximity = false,
  auto_resume = false
}
@dholmes215
Copy link
Contributor Author

This was basically 0.B, build by me in Cygwin.

@KA101 KA101 added the <Crash / Freeze> Fatal bug that results in hangs or crashes. label Jan 23, 2015
@KA101 KA101 added this to the 0.C milestone Jan 23, 2015
@kevingranade
Copy link
Member

I haven't had any luck reproducing it, the only possibility that jumps out at me is that the implicit player_activity() constructor called by player::cancel_activity() isn't clearing player_activity::type.
Unfortunately can't test this theory without a reproduction case.

@kevingranade
Copy link
Member

Managed to reproduce, yay? No closer to figuring out what's happening though, deduction tells me something in player::complete_craft() is resetting the activity.

@kevingranade
Copy link
Member

Wow that's just odd, here's the backtrace:

#0 player::cancel_activity (this=0xf74d91d4) at src/player.cpp:12614
#1 0x081fbc25 in game::cancel_activity_query (this=0xf7488008, message=0x8a1ce12 "%s spotted!") at src/game.cpp:1658
#2 0x08218d9f in game::mon_info (this=0xf7488008, w=0x9b83b88) at src/game.cpp:5717
#3 0x08215852 in game::draw_sidebar (this=0xf7488008) at src/game.cpp:5027
#4 0x082149d8 in game::draw (this=0xf7488008) at src/game.cpp:4915
#5 0x08216871 in game::refresh_all (this=0xf7488008) at src/game.cpp:5160
#6 0x0823836c in game::handle_liquid (this=0xf7488008, liquid=..., from_ground=false, infinite=false, source=0x0, cont=0x0) at src/game.cpp:9821
#7 0x088174c5 in set_item_inventory (newit=...) at src/crafting.cpp:1580
#8 0x08816bce in player::complete_craft (this=0xf74d91d4) at src/crafting.cpp:1537
#9 0x080e15f8 in player_activity::finish (this=0xf74d9718, p=0xf74d91d4) at src/player_activity.cpp:235
#10 0x080e14e4 in player_activity::do_turn (this=0xf74d9718, p=0xf74d91d4) at src/player_activity.cpp:208
#11 0x081fb5e7 in game::process_activity (this=0xf7488008) at src/game.cpp:1589
#12 0x081f9b3c in game::do_turn (this=0xf7488008) at src/game.cpp:1405
#13 0x0864d18a in main (argc=0, argv=0xffceb418) at src/main.cpp:295

In English, code inside complete_craft() triggered drawing which in turn triggered an interruption check, which wiped the activity while it was still in-use, causing the crash. There are two fixes for this, the one I'm going to make is removing the access of activity after complete_craft() is called. The more complete fix is disentangling checking for interruptions from the drawing code, which needs to happen at some point because this is loopy, but not something I want to tackle right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants