Ask Your Question

[costmap] memory out of bounds when costmap do initMaps

asked 2018-02-09 03:48:48 -0500

Jam gravatar image

Dear all,
I am using costmap and frontier_exploration for my robot autonomous exploration.
Now I encountered a costmap memory of bounds problem when static layer do incomingMap function.
(the error log shows "corrupted double-linked list" or "free(): invalid next size (normal)")

my costmap_2d version: 1.12.13 (2016-08-15)

I add "launch-prefix="valgrind --tool=memcheck --leak-check=full" in my launch file in order to get more detail log.
here is part of log:

==1806== Invalid write of size 1
==1806==    at 0x4FB5AF8: costmap_2d::CostmapLayer::updateWithTrueOverwrite(costmap_2d::Costmap2D&, int, int, int, int) (costmap_layer.cpp:85)
==1806==    by 0x13DFBC1F: costmap_2d::StaticLayer::updateCosts(costmap_2d::Costmap2D&, int, int, int, int) (static_layer.cpp:300)
==1806==    by 0x4F5273D: costmap_2d::LayeredCostmap::updateMap(double, double, double) (layered_costmap.cpp:137)
==1806==    by 0x4F59134: costmap_2d::Costmap2DROS::updateMap() (costmap_2d_ros.cpp:429)
==1806==    by 0x4F5894C: costmap_2d::Costmap2DROS::mapUpdateLoop(double) (costmap_2d_ros.cpp:389)
==1806==    by 0x4FA098E: boost::_mfi::mf1<void, costmap_2d::Costmap2DROS, double>::operator()(costmap_2d::Costmap2DROS*, double) const (mem_fn_template.hpp:165)
==1806==    by 0x4F9F49A: void boost::_bi::list2<boost::_bi::value<costmap_2d::Costmap2DROS*>, boost::_bi::value<double> >::operator()<boost::_mfi::mf1<void, costmap_2d::Costmap2DROS, double>, boost::_bi::list0>(boost::_bi::type<void>, boost::_mfi::mf1<void, costmap_2d::Costmap2DROS, double>&, boost::_bi::list0&, int) (bind.hpp:313)
==1806==    by 0x4F9DF04: boost::_bi::bind_t<void, boost::_mfi::mf1<void, costmap_2d::Costmap2DROS, double>, boost::_bi::list2<boost::_bi::value<costmap_2d::Costmap2DROS*>, boost::_bi::value<double> > >::operator()() (bind_template.hpp:20)
==1806==    by 0x4F9A7A9: boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf1<void, costmap_2d::Costmap2DROS, double>, boost::_bi::list2<boost::_bi::value<costmap_2d::Costmap2DROS*>, boost::_bi::value<double> > > >::run() (thread.hpp:117)
==1806==    by 0x66D5A49: ??? (in /usr/lib/x86_64-linux-gnu/
==1806==    by 0x68E8183: start_thread (pthread_create.c:312)
==1806==    by 0x61E8FFC: clone (clone.S:111)
==1806==  Address 0x16e0b7a0 is 0 bytes after a block of size 135,168 alloc'd
==1806==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/
==1806==    by 0x4F3D071: costmap_2d::Costmap2D::initMaps(unsigned int, unsigned int) (costmap_2d.cpp:71)
==1806==    by 0x4F3D915: costmap_2d::Costmap2D::resizeMap(unsigned int, unsigned int, double, double, double) (costmap_2d.cpp:91)
==1806==    by 0x4F51996: costmap_2d::LayeredCostmap::resizeMap(unsigned int, unsigned int, double, double, double, bool) (layered_costmap.cpp:71)
==1806==    by 0x13DFB26F: costmap_2d::StaticLayer::incomingMap(boost::shared_ptr<nav_msgs::OccupancyGrid_<std::allocator<void> > const> const&) (static_layer.cpp:182)
==1806==    by 0x13E07895: boost::_mfi::mf1<void, costmap_2d::StaticLayer, boost::shared_ptr<nav_msgs::OccupancyGrid_<std::allocator<void> > const> const&>::operator()(costmap_2d::StaticLayer*, boost::shared_ptr<nav_msgs::OccupancyGrid_<std::allocator<void> > const> const&) const (mem_fn_template.hpp:165)
==1806==    by 0x13E06A03: void boost::_bi::list2<boost::_bi::value<costmap_2d::StaticLayer*>, boost::arg<1> >::operator()<boost::_mfi::mf1<void, costmap_2d::StaticLayer, boost::shared_ptr<nav_msgs::OccupancyGrid_<std::allocator<void> > const> const&>, boost::_bi::list1<boost::shared_ptr<nav_msgs::OccupancyGrid_<std::allocator<void> > const> const&> >(boost::_bi::type<void>, boost::_mfi::mf1<void, costmap_2d::StaticLayer, boost::shared_ptr<nav_msgs::OccupancyGrid_<std::allocator<void> > const> const&>&, boost::_bi::list1<boost::shared_ptr<nav_msgs::OccupancyGrid_<std::allocator<void> > const> const&>&, int) (bind.hpp:313)
==1806==    by 0x13E05FC1: void boost ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-02-12 03:01:33 -0500

Jam gravatar image

I think I found the out of memory crash reason.

when costmap do layered_costmap_->resizeMap() in static_layer incomingMap function.
the "master" costmap(which combine all plugin layer) will do resizeMap first.
it will first change size_x_, size_y_...etc .
and then initMaps ( lock costmap -> delete costmap -> new costmap)
so when I use my UpdateWithMax function, I use master_grid.getSizeInCellsX() try to get costmap size_x_.
but at that time, real costmap size is still old one.
and the UpdateWithMax function will cause out of memory problem.

I will keep tracing if there are other possible reasons which may be the root cause.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-02-09 03:48:48 -0500

Seen: 76 times

Last updated: Feb 12 '18