- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
on Mac OS X with open source TBB 4.1 consider
class A { //copyable class, good for tbb::movable_exception
public:
A(size_t n) : m_n(n) {}
size_t getN() const {return m_n;}
private:
size_t m_n;
};
class TBBTry {
public:
void operator() ( const tbb::blocked_range<size_t>& r ) const {
for ( size_t i = r.begin(); i != r.end(); ++i ) {
if (((i+1) % 4) == 0) {
size_t n = i + 100;
throw tbb::movable_exception<A>(A(n));
}
}
}
TBBTry() { }
};
int main() {
try {
tbb::parallel_for(tbb::blocked_range<size_t>(0, 5 ), TBBTry() );
} catch ( tbb::movable_exception<A> &ex) {
std::cout << "tbb::movable_exception n = " << ex.data().getN() << std::endl;
} catch ( tbb::captured_exception &ex ) {
std::cout << "tbb::captured_exception name = " << ex.name() << "; " << ex.what() << std::endl;
} catch ( ... ) {
std::cout << "unknown_exception" << std::endl;
}
return 0;
}
I expect to see
tbb::movable_exception n = 103
However I see the following output:
tbb::captured_exception name = N3tbb17movable_exceptionI1AEE; tbb::movable_exception
I debugged that issue and found out that we have problem with visibility template exception thrown from separate dll.
Problem is fixed if I do the following changes in the file
tbb_exception.h:
#ifndef __TBB_exception_H
#define __TBB_exception_H
# pragma GCC visibility push (default) //xxx(dmarkman)
...........
# pragma GCC visibility pop //xxx(dmarkman)
#endif /* __TBB_exception_H */
I sbmitted bug report but didn't get back any bugid and when I search bug db I'm getting no records
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is this problem fixed ? If so, can anyone point me to the release version when it was fixed ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With std::exception_ptr available since C++11, TBB can propagate exceptions keeping their original types. For example, the code in question can be rewritten as
int main() { try { tbb::parallel_for(tbb::blocked_range<size_t>(0, 5 ), [] ( const tbb::blocked_range<size_t>& r ) { for ( size_t i = r.begin(); i != r.end(); ++i ) { if ( (i+1) % 4 == 0) { throw A{i + 100}; } } } ); } catch ( A &ex) { std::cout << "exception A; n = " << ex.getN() << std::endl; } catch ( std::exception &ex ) { std::cout << "std::exception: " << ex.what() << std::endl; } catch ( ... ) { std::cout << "unknown exception" << std::endl; } return 0; }
It makes the old TBB exception classes to be of no value; they will likely be deprecated, so you should better not use them these days.
For OS X / macOS, exact exception propagation is supported since TBB 4.2.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page