Open coo1berg opened 4 months ago
I can reproduce the issue. It does appear that sometimes the right zombie child self destructs without being fully constructed.
If that helps, here is a little patch that fixes lifetime problem for me
diff --git a/include/oneapi/tbb/parallel_scan.h b/include/oneapi/tbb/parallel_scan.h
index d624f7eb..b9169b97 100644
--- a/include/oneapi/tbb/parallel_scan.h
+++ b/include/oneapi/tbb/parallel_scan.h
@@ -94,6 +94,7 @@ private:
wait_context& m_wait_context;
sum_node_type* m_parent = nullptr;
+ bool m_alive = false;
public:
small_object_allocator m_allocator;
final_sum( Body& body, wait_context& w_o, small_object_allocator& alloc ) :
@@ -107,13 +108,15 @@ public:
}
~final_sum() {
- m_range.begin()->~Range();
+ if (m_alive)
+ m_range.begin()->~Range();
}
void finish_construction( sum_node_type* parent, const Range& range, Body* stuff_last ) {
__TBB_ASSERT( m_parent == nullptr, nullptr );
m_parent = parent;
new( m_range.begin() ) Range(range);
m_stuff_last = stuff_last;
+ m_alive = true;
}
private:
sum_node_type* release_parent() {
Of course, it doesn't fix the cause of why it wants to self destruct at wrong time.
We are still looking into why the object is left uninitialized. Meanwhile, I hope that you are able to use the workaround (even a simple if (m_parent)
check would work).
Hi,
I've faced odd crash using parallel_scan over range object that has some logic inside its destructor. It seems that destructor of range sometimes called on not yet constructed range object.
It happens not 100% times, but there is a minimal reproducible example I managed to get (ensure asserts are on):
tbb.cpp.txt
Tested on:
Is there a problem inside my code?
Regards, Slava