From 22dc80e4ffe87f4dc0225b6317a0a8f54d57d23d Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 10 Sep 2013 15:45:12 +0000 Subject: [PATCH] Attempting to fix a TBB crash --- gtsam/base/treeTraversal-inst.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gtsam/base/treeTraversal-inst.h b/gtsam/base/treeTraversal-inst.h index 2d3c135ad..9cf9ad41c 100644 --- a/gtsam/base/treeTraversal-inst.h +++ b/gtsam/base/treeTraversal-inst.h @@ -107,9 +107,12 @@ namespace gtsam { tbb::task_list childTasks; BOOST_FOREACH(const boost::shared_ptr& child, node->children) { - // Process child in a subtask + // Process child in a subtask. Important: Run visitorPre before calling + // allocate_child so that if visitorPre throws an exception, we will not have + // allocated an extra child, this causes a TBB error. + const DATA childData = visitorPre(child, myData); childTasks.push_back(*new(allocate_child()) - PreOrderTask(child, visitorPre(child, myData), visitorPre, visitorPost, + PreOrderTask(child, childData, visitorPre, visitorPost, problemSizeThreshold, overThreshold)); }