mspraggs / potentia

Southampton Game Jam 2015
0 stars 0 forks source link

Segfault on return to starting menu after death #52

Closed mspraggs closed 9 years ago

mspraggs commented 9 years ago

I get the following stacktrace if I play for bit then die, return to the menu and try and freeze the water there:

#0  0x00007ffff7bc5f28 in __gnu_cxx::new_allocator<Object*>::construct<Object*<Object* const&> > (this=0x7ffff7de9557 <_dl_fixup+247>, __p=0xa6850fc085000000) at /usr/include/c++/4.8/ext/new_allocator.h:120
#1  0x00007ffff7bc5a6e in std::allocator_traits<std::allocator<Object*> >::_S_construct<Object*<Object* const&> >(std::allocator<Object*>&, std::allocator_traits<std::allocator<Object*> >::__construct_helper*, (Object*<Object* const&>&&)...) (__a=..., __p=0xa6850fc085000000) at /usr/include/c++/4.8/bits/alloc_traits.h:254
#2  0x00007ffff7bc53cf in std::allocator_traits<std::allocator<Object*> >::construct<Object*<Object* const&> >(std::allocator<Object*>&, Object*<Object* const&>*, (Object*<Object* const&>&&)...) (__a=..., __p=0xa6850fc085000000)
at /usr/include/c++/4.8/bits/alloc_traits.h:393
#3  0x00007ffff7bc4184 in std::vector<Object*, std::allocator<Object*> >::push_back (this=0x7ffff7de9557 <_dl_fixup+247>, __x=@0x7fffffffb470: 0x1b3b310) at /usr/include/c++/4.8/bits/stl_vector.h:905
#4  0x00007ffff7bbc5c2 in Room::addObject (this=0x7ffff7de9557 <_dl_fixup+247>, add=0x1b3b310) at /home/matthew/Programming/C++/potentia/lib/Room.cpp:56
#5  0x00007ffff7bbc702 in Room::genBullet (this=0x7ffff7de9557 <_dl_fixup+247>, data=..., pos=...) at /home/matthew/Programming/C++/potentia/lib/Room.cpp:60
#6  0x00007ffff7bb63e4 in Player::update (this=0x7fffffffb720) at /home/matthew/Programming/C++/potentia/lib/Player.cpp:71
#7  0x00007ffff7bbc3fa in Room::update (this=0x7fffffffb810) at /home/matthew/Programming/C++/potentia/lib/Room.cpp:27
#8  0x00007ffff7ba33a8 in World::update (this=0x7fffffffb800) at /home/matthew/Programming/C++/potentia/lib/World.cpp:217
#9  0x00007ffff7bac65e in Game::update (this=0x7fffffffb720) at /home/matthew/Programming/C++/potentia/lib/Game.cpp:114
#10 0x00007ffff7bac091 in Game::run (this=0x7fffffffb720) at /home/matthew/Programming/C++/potentia/lib/Game.cpp:25
#11 0x0000000000403fb4 in main () at /home/matthew/Programming/C++/potentia/lib/main.cpp:13
mspraggs commented 9 years ago

Hmm... If I go to frame 4 (addObject) and print the size of objects_, I get 17423302598739840727, so I think we have a memory leak somewhere.

Fyll commented 9 years ago

Never fear, it's been fixed (sorry, I didn't see your self-assignment).

It was because when Player gets re-initialised when the game resets, I forgot to pass him the pointer to the current room, so he was accessing an un-initialised pointer. All fixed and pushed.