[Segmentation fault] when sleeping (maybe caused by inital NPC)

Hey guys,

Thanks for the great game, and because it’s so awesome I want to contribute :slight_smile:
I found a bug, that causes a segmentation fault.
It appears when i’m sleeping but is maybe caused by the starting NPC
Here is the the bugtrack

Program received signal SIGSEGV, Segmentation fault.   │West:                          East:
0x00007ffff6e4059c in free () from /lib/x86_64-linux-gnu/libc.so.6     South:            SE:
(gdb) where######################################│  +  │
#0  0x00007ffff6e4059c in free () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x0000000000a67672 in __gnu_cxx::new_allocator<npc_need>::deallocate (this=0x293d730, __p=0xffffffff00000000) at /usr/include/c++/4.7/ext/new_allocator.h:100
#2  0x0000000000a65c90 in std::_Vector_base<npc_need, std::allocator<npc_need> >::_M_deallocate (this=0x293d730, __p=0xffffffff00000000, __n=1073741836) at /usr/include/c++/4.7/bits/stl_vector.h:175
#3  0x0000000000a6585f in std::_Vector_base<npc_need, std::allocator<npc_need> >::~_Vector_base (this=0x293d730, __in_chrg=<optimized out>) at /usr/include/c++/4.7/bits/stl_vector.h:161
#4  0x0000000000a64854 in std::vector<npc_need, std::allocator<npc_need> >::~vector (this=0x293d730, __in_chrg=<optimized out>) at /usr/include/c++/4.7/bits/stl_vector.h:404
#5  0x0000000000a3ed00 in npc::~npc (this=0x293cf30, __in_chrg=<optimized out>) at npc.cpp:57
#6  0x00000000005562ce in __gnu_cxx::new_allocator<npc>::destroy (this=0x7ffff7fcf6a8, __p=0x293cf30) at /usr/include/c++/4.7/ext/new_allocator.h:123
#7  0x0000000000556235 in __gnu_cxx::__alloc_traits<std::allocator<npc> >::destroy (__a=..., __p=0x293cf30) at /usr/include/c++/4.7/ext/alloc_traits.h:205
#8  0x00000000005ea93c in std::vector<npc, std::allocator<npc> >::erase (this=0x7ffff7fcf6a8, __position=...) at /usr/include/c++/4.7/bits/vector.tcc:141
#9  0x00000000008c8d20 in mission_fail::kill_npc (this=0x7fffffffdeeb, g=0x7ffff7ef2010, miss=0x293afe0) at mission_fail.cpp:9
#10 0x000000000059bef9 in game::fail_mission (this=0x7ffff7ef2010, id=1) at game.cpp:1391
#11 0x000000000059c12f in game::process_missions (this=0x7ffff7ef2010) at game.cpp:1422
#12 0x00000000005972c5 in game::do_turn (this=0x7ffff7ef2010) at game.cpp:615
#13 0x000000000076ae54 in main (argc=0, argv=0x7fffffffe1d0) at main.cpp:6

Another thing that let my program crash is when I ask the NPC to teach me something as a reward, and then change my mind (decline training)

Thanks devs!

EDIT: Newest git version btw

So apparently NPCs die when you don’t find their dog.

If it’s only the needs vector that’s corrupt, I’m guessing the needs vector isn’t initialized for the initial npc. They don’t actually move around or have any sort of goal, right?

Yeah if I remember correctly, this may caused the bug.

They can turn hostile if you keep talking to them.