From: Jiri Vlasak Date: Fri, 11 Jan 2019 13:54:34 +0000 (+0100) Subject: Fix heap-use-after-free error when T3 is used X-Git-Tag: v0.4.0~1^2~11 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/iamcar.git/commitdiff_plain/76e3f5213c17c6b9a1f9dff5ef205f26f1a4706c Fix heap-use-after-free error when T3 is used As T3 shares some resources with two T2 planners `p_root_` and `p_goal_` the problem with descructors occures. Therefore, all the code needed for destructing T3 planner and both T2 planners (`p_root_` and `p_goal_`) is in T3 destructor method (`T3::~T3()`) and T2 destructor (and its parent destructors) must not be called. If only T2 planner should be used, this patch has to be *reverted*. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index a661d1b..d829250 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ The format is based on [Keep a Changelog][] and this project adheres to - Refactor `gplot` module. - T2 planner to include variable steer step size. +### Removed +- RRTBase planner destructor. See `base/rrtbase.cc` for more info. + ## 0.3.0 - 2018-12-03 ### Added - Cost distribution plot function. diff --git a/base/rrtbase.cc b/base/rrtbase.cc index b9ff749..3a0158b 100644 --- a/base/rrtbase.cc +++ b/base/rrtbase.cc @@ -37,20 +37,23 @@ extern SDL_GLContext gc; RRTBase::~RRTBase() { - for (auto n: this->nodes_) - if (n != this->root_) - delete n; - for (auto n: this->dnodes_) - if (n != this->root_ && n != this->goal_) - delete n; - for (auto s: this->samples_) - if (s != this->goal_) - delete s; - for (auto edges: this->rlog_) - for (auto e: edges) - delete e; - delete this->root_; - delete this->goal_; +// Fix heap-use-after-free error when T3 planner is used. If only T2 is used, +// please uncommend the following code: +// +// for (auto n: this->nodes_) +// if (n != this->root_) +// delete n; +// for (auto n: this->dnodes_) +// if (n != this->root_ && n != this->goal_) +// delete n; +// for (auto s: this->samples_) +// if (s != this->goal_) +// delete s; +// for (auto edges: this->rlog_) +// for (auto e: edges) +// delete e; +// delete this->root_; +// delete this->goal_; } RRTBase::RRTBase():