- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I've found that when an exception is thrown during execution of a flow graph node task, the exception propagates upward to the main thread as expected but cancellation of tasks does not seem to take place as described in Section 5.2 (page 39) of the tutorial. The result is that subsequent calls to graph.wait_for_all() hang. Notably, since wait_for_all() is called during the graph object's destructor, an exception which should kill the process instead causes it to hang as the graph object goes out of scope and its destructor is called. Here is some simple example code demonstrating the problem:
I've found that when an exception is thrown during execution of a flow graph node task, the exception propagates upward to the main thread as expected but cancellation of tasks does not seem to take place as described in Section 5.2 (page 39) of the tutorial. The result is that subsequent calls to graph.wait_for_all() hang. Notably, since wait_for_all() is called during the graph object's destructor, an exception which should kill the process instead causes it to hang as the graph object goes out of scope and its destructor is called. Here is some simple example code demonstrating the problem:
[cpp]#include
#include
#include
class Foo {
private:
std::vector& m_vec;
public:
Foo(std::vector& vec) : m_vec(vec) { }
void operator() (tbb::flow::continue_msg) const {
m_vec.at(m_vec.size()); // Will throw out_of_range exception
}
};
int main() {
// Initializes body
std::vector vec;
vec.push_back(0);
Foo f(vec);
// Constructs graph and nodes
tbb::flow::graph g;
tbb::flow::broadcast_node<:FLOW::CONTINUE_MSG> start(g);
tbb::flow::continue_node<:FLOW::CONTINUE_MSG> fooNode(g, f);
// Constructs edge
tbb::flow::make_edge(start, fooNode);
// Executes graph
std::cout << "Executing" << std::endl;
try {
start.try_put(tbb::flow::continue_msg());
g.wait_for_all();
}
catch(std::out_of_range& ex) {
std::cout << "Exception: " << ex.what() << std::endl;
}
std::cout << "Finished" << std::endl;
return 0;
}[/cpp] The above code will hang upon returning 0. Is this expected behaviour? Do I have to cancel all tasks in the graph manually somehow?
Thanks,
Andrew
Thanks,
Andrew
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andrew,
thanks for reporting the problem. It certainly looks like a bug; we will investigate it.
thanks for reporting the problem. It certainly looks like a bug; we will investigate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cool, thanks! Also the above only works on Windows - on Linux, an exception of type tbb::captured_exception is thrown.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page