]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Fix heap-use-after-free error when T3 is used
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Fri, 11 Jan 2019 13:54:34 +0000 (14:54 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 16 Jan 2019 08:30:50 +0000 (09:30 +0100)
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*.

CHANGELOG.md
base/rrtbase.cc

index a661d1bd8ec9f3406f85fee74d016ac24500cd8d..d829250b6f9f66a24ce33514348828e2d13b6a66 100644 (file)
@@ -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.
index b9ff749150ec10db99ae9f60a03474f37f1c0751..3a0158be9891e7f759a9c6205ce24f6fefcf007d 100644 (file)
@@ -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():