Closed richelbilderbeek closed 5 years ago
Start at the first:
==14823== Invalid write of size 8
==14823== at 0x410D6C: agent::reproduce_agents(game&, agent_type) (agent.cpp:317)
==14823== by 0x40EF76: agent::process_events(game&) (agent.cpp:231)
==14823== by 0x42F22D: game::process_events() (game.cpp:61)
==14823== by 0x41A811: test_agent() (agent.cpp:909)
==14823== by 0x4B9FA2: test() (main.cpp:43)
==14823== by 0x4BAF6F: main (main.cpp:100)
==14823== Address 0x161bf8c0 is 32 bytes inside a block of size 48 free'd
==14823== at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14823== by 0x428B99: __gnu_cxx::new_allocator<agent>::deallocate(agent*, unsigned long) (new_allocator.h:110)
==14823== by 0x4280F7: std::allocator_traits<std::allocator<agent> >::deallocate(std::allocator<agent>&, agent*, unsigned long) (alloc_traits.h:462)
==14823== by 0x42658C: std::_Vector_base<agent, std::allocator<agent> >::_M_deallocate(agent*, unsigned long) (stl_vector.h:178)
==14823== by 0x425556: void std::vector<agent, std::allocator<agent> >::_M_emplace_back_aux<agent const&>(agent const&) (vector.tcc:438)
==14823== by 0x4222F3: std::vector<agent, std::allocator<agent> >::push_back(agent const&) (stl_vector.h:924)
==14823== by 0x4489B1: std::back_insert_iterator<std::vector<agent, std::allocator<agent> > >::operator=(agent const&) (stl_iterator.h:489)
==14823== by 0x44734B: std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m<agent const*, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > >(agent const*, agent const*, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > >) (stl_algobase.h:324)
==14823== by 0x444A4C: std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > std::__copy_move_a<false, agent const*, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > >(agent const*, agent const*, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > >) (stl_algobase.h:386)
==14823== by 0x4405FA: std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > std::__copy_move_a2<false, __gnu_cxx::__normal_iterator<agent const*, std::vector<agent, std::allocator<agent> > >, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > >(__gnu_cxx::__normal_iterator<agent const*, std::vector<agent, std::allocator<agent> > >, __gnu_cxx::__normal_iterator<agent const*, std::vector<agent, std::allocator<agent> > >, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > >) (stl_algobase.h:424)
==14823== by 0x43C3AD: std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > std::copy<__gnu_cxx::__normal_iterator<agent const*, std::vector<agent, std::allocator<agent> > >, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > > >(__gnu_cxx::__normal_iterator<agent const*, std::vector<agent, std::allocator<agent> > >, __gnu_cxx::__normal_iterator<agent const*, std::vector<agent, std::allocator<agent> > >, std::back_insert_iterator<std::vector<agent, std::allocator<agent> > >) (stl_algobase.h:456)
==14823== by 0x42EB8B: game::add_agents(std::vector<agent, std::allocator<agent> > const&) (game.cpp:35)
Some clear findings: this is caused by implicit conversions:
any_double += 1; //Wrong: implicit conversion to double
any_double += 1.0; //Correct: using a double
There is a problem with SFML: it uses float
by default (as per history), where we using double
by default (as is preferred)
Good enough for now...
Is your feature request related to a problem? Please describe.
memcheck detects a lot of errors:
results in this Travis log:
Describe the solution you'd like
Find out what is the problem and fix it.
Describe alternatives you've considered
None.
Additional context
None.