concurrent_monitor bug

concurrent_monitor bug

There is a bug in concurrent_monitor.cpp/h when compiled withTBB_USE_ASSERT=1 TBB_USE_DEBUG=0

There is an assertion in the concurrent_monitor destructor which verify the waitset is empty, but in four places inside this files the waitset is cleared only where TBB_USE_DEBUG is true (look for "temp.clear()").

When compiled with previously mentioned settings, the waitset is not cleared and the assertion in the constructor fails.

I patched the #if's, the minimal change to be able to build, and I'llsubmit the patch though the submision form ASAP.

The waitset is in all the 4 places a temporary object and the clear() is the last instruction before the end of the definition scope, so the #if seems OK, since the clear function only resets value of some internal variables.
void clear() { = &head; head.prev = &head;__TBB_store_relaxed(count, 0);}

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I guess you meant ~circular_doubly_linked_list_with_sentinel(), instead of ~concurrent_monitor()? That I would confirm, although I only see 3 such uses in concurrent_monitor.{h,cpp}, instead of 4.

Excuse me, you are right in both comments.

I'm talking about thecircular_doubly_linked_list_with_sentinel destructor not the concurrent_monitor one.

There are only 3 "temp.clear()", the fourth correction is in the "#if !TBB_USE_DEBUG" around the private keyword incircular_doubly_linked_list_with_sentinel which must be changed to "#if !TBB_USE_DEBUG && !TBB_USE_ASSERT".

How about this?

    void clear() { = &head; head.prev = &head;__TBB_store_relaxed(count, 0);}
    __TBB_atomic size_t count;
    node_t head;

Yes, it is OK, the TBB_USE_DEBUG isn't needed here.

Could you give us more detail?
I don't seem to reproduce the issue.
temp.clear() is wrappend around by '#if TBB_USE_ASSERT', it is called when TBB_USE_ASSERT==1; and __TBB_ASSERT is defined when TBB_USE_ASSERT==1.
And, could you check if you have the latest TBB release?


I suppose it is because someone patch the bug after I report it.


This is the code in version 20111130, which was the most recent one when I report the issue.
As you can see it uses TBB_USE_DEBUG instead of TBB_USE_ASSERT

That seems to be the case. Thanks.!!
The fix will be in the next TBB release.

Leave a Comment

Please sign in to add a comment. Not a member? Join today