HuaYuXiao / Fast-Planner

[RA-L 2019] A Robust and Efficient Trajectory Planner for Quadrotors
GNU General Public License v3.0
1 stars 0 forks source link

free(): double free detected in tcache 2 #45

Open HuaYuXiao opened 2 months ago

HuaYuXiao commented 2 months ago
free(): double free detected in tcache 2
Stack trace (most recent call last):
#25   Object "[0xffffffffffffffff]", at 0xffffffffffffffff, in 
#24   Object "/home/hyx020222/planner_ws/devel/lib/prometheus_plan_manage/dyn_planner_node", at 0x55b8dd7d5ded, in _start
#23   Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f2ad706b082, in __libc_start_main
#22   Object "/home/hyx020222/planner_ws/devel/lib/prometheus_plan_manage/dyn_planner_node", at 0x55b8dd7d5864, in main
#21   Object "/opt/ros/noetic/lib/libroscpp.so", at 0x7f2ad775f21e, in ros::spin()
#20   Object "/opt/ros/noetic/lib/libroscpp.so", at 0x7f2ad7776fce, in ros::SingleThreadedSpinner::spin(ros::CallbackQueue*)
#19   Object "/opt/ros/noetic/lib/libroscpp.so", at 0x7f2ad7723882, in ros::CallbackQueue::callAvailable(ros::WallDuration)
#18   Object "/opt/ros/noetic/lib/libroscpp.so", at 0x7f2ad7722171, in ros::CallbackQueue::callOneCB(ros::CallbackQueue::TLS*)
#17   Object "/opt/ros/noetic/lib/libroscpp.so", at 0x7f2ad7700607, in ros::TimerManager<ros::Time, ros::Duration, ros::TimerEvent>::TimerQueueCallback::call()
#16   Object "/home/hyx020222/planner_ws/devel/lib/prometheus_plan_manage/dyn_planner_node", at 0x55b8dd7e42fd, in dyn_planner::PlanningFSM::execFSMCallback(ros::TimerEvent const&)
#15   Object "/home/hyx020222/planner_ws/devel/lib/prometheus_plan_manage/dyn_planner_node", at 0x55b8dd7e35cf, in dyn_planner::PlanningFSM::planSearchOpt()
#14   Object "/home/hyx020222/planner_ws/devel/lib/prometheus_plan_manage/dyn_planner_node", at 0x55b8dd7f3569, in dyn_planner::DynPlannerManager::generateTrajectory(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>)
#13   Object "/home/hyx020222/planner_ws/devel/lib/libbspline_opt.so", at 0x7f2ad7892522, in dyn_planner::BsplineOptimizer::optimize(int, bool, double)
#12   Object "/usr/local/lib/libnlopt.so.0", at 0x7f2ad6f89cd3, in nlopt_optimize
#11   Object "/usr/local/lib/libnlopt.so.0", at 0x7f2ad6f4212a, in luksan_plis
#10   Object "/home/hyx020222/planner_ws/devel/lib/libbspline_opt.so", at 0x7f2ad7893f79, in nlopt::opt::myvfunc(unsigned int, double const*, double*, void*)
#9    Object "/home/hyx020222/planner_ws/devel/lib/libbspline_opt.so", at 0x7f2ad7891e58, in dyn_planner::BsplineOptimizer::costFunction(std::vector<double, std::allocator<double> > const&, std::vector<double, std::allocator<double> >&, void*)
#8    Object "/home/hyx020222/planner_ws/devel/lib/libbspline_opt.so", at 0x7f2ad7891639, in dyn_planner::BsplineOptimizer::combineCost(std::vector<double, std::allocator<double> > const&, std::vector<double, std::allocator<double> >&, double&)
#7    Object "/home/hyx020222/planner_ws/devel/lib/libbspline_opt.so", at 0x7f2ad7890a4b, in dyn_planner::BsplineOptimizer::calcDistanceCost(std::vector<Eigen::Matrix<double, 3, 1, 0, 3, 1>, std::allocator<Eigen::Matrix<double, 3, 1, 0, 3, 1> > > const&, double&, std::vector<Eigen::Matrix<double, 3, 1, 0, 3, 1>, std::allocator<Eigen::Matrix<double, 3, 1, 0, 3, 1> > >&)
#6    Object "/home/hyx020222/planner_ws/devel/lib/libplan_env.so", at 0x7f2ad7865ca6, in dyn_planner::EDTEnvironment::evaluateEDTWithGrad(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, double const&, double&, Eigen::Matrix<double, 3, 1, 0, 3, 1>&)
#5    Object "/home/hyx020222/planner_ws/devel/lib/libplan_env.so", at 0x7f2ad784d484, in 
#4    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f2ad70ddf6c, in 
#3    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f2ad70dc2fb, in 
#2    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f2ad70d426d, in 
#1    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f2ad7069858, in abort
#0    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f2ad708a00b, in gsignal
Aborted (Signal sent by tkill() 63951 1000)
[dyn_planner_node-20] process has died [pid 63951, exit code -6, cmd /home/hyx020222/planner_ws/devel/lib/prometheus_plan_manage/dyn_planner_node /prometheus/planning/global_pcl:=/octomap_point_cloud_centers __name:=dyn_planner_node __log:=/home/hyx020222/.ros/log/5c1ea8ce-021b-11ef-91e7-33ed52407f43/dyn_planner_node-20.log].
log file: /home/hyx020222/.ros/log/5c1ea8ce-021b-11ef-91e7-33ed52407f43/dyn_planner_node-20*.log
HuaYuXiao commented 2 months ago

错误信息free(): double free detected in tcache 2表明程序试图释放同一块内存两次。这通常是由于程序中存在内存管理错误,可能是以下几个原因:

  1. 重复释放:代码中可能存在对同一块动态分配的内存执行了两次free()

  2. 使用野指针:指针可能未正确初始化或已经被释放,但随后又被错误地使用。

  3. 内存越界:数组或缓冲区可能越界,导致相邻内存被错误地覆盖。

  4. 并发问题:在多线程环境中,如果内存的分配和释放没有适当的同步机制,可能会导致内存错误。

  5. 库的bug:使用的库可能存在bug,导致内存管理不当。

解决步骤:

  1. 调试程序:使用内存检测工具,如Valgrind,来检测内存泄漏和错误。

  2. 审查代码:检查dyn_planner_node的源代码,特别是PlanningFSM::execFSMCallbackBsplineOptimizer::optimize等函数,以确定是否有重复释放内存的情况。

  3. 更新和维护代码:如果这是第三方库或代码的一部分,请检查是否有更新或补丁。

  4. 并发控制:如果程序是多线程的,确保对共享资源的访问有适当的同步。

  5. 简化问题:尝试简化问题,注释掉部分代码或逐步执行,以确定导致错误的确切位置。

  6. 日志文件:查看/home/hyx020222/.ros/log/5c1ea8ce-021b-11ef-91e7-33ed52407f43/dyn_planner_node-20*.log中的日志,这可能会给出为什么进程终止的更多信息。

  7. 咨询社区:如果问题依旧存在,考虑在ROS社区论坛或相关的技术社区中寻求帮助。

  8. 重新启动节点:在解决了问题后,重新启动dyn_planner_node

  9. 安全编程实践:采用更安全的编程实践,如使用智能指针来自动管理内存。

请注意,内存管理错误可能是复杂和难以调试的,可能需要深入的代码审查和调试。如果你不熟悉这些概念,可能需要寻求专业的帮助。