Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

bug in concurrent_bounded_queue?

pp0
Beginner
3,063 Views

Hi there,

The snippet below will crash after a while with an access violation somewhere below tbb_debug.dll!concurrent_queue_base_v3::internal_push() when running 1 tbb thread for consume() and 10 for produce(). This is reproducible on my Vista 64 Box (snippet is compiled to 32 bits/debug). I am using Studio 2008 SP1. Any ideas?

struct QueuedCall
{
void unblock() { myQueue.push(1); }
void block() {
int dummy;
myQueue.pop(dummy);
}

tbb::concurrent_bounded_queue myQueue;
};

tbb::concurrent_queue myPendingCalls;

void consume() {
do {
QueuedCall *call;
if (myPendingCalls.try_pop(call))
call->unblock();
} while (true);
}

void produce() {
for (;;) {
QueuedCall *c = new QueuedCall();
myPendingCalls.push(c);
c->block();
delete c;
}
}

0 Kudos
88 Replies
Dmitry_Vyukov
Valued Contributor I
210 Views
I guess you are looking at concurrent_bounded_queue.
0 Kudos
RafSchietekat
Valued Contributor III
210 Views
"I guess you are looking at concurrent_bounded_queue."
concurrent_queue.h:408: "using strict_ppl::concurrent_queue;"
concurrent_queue.h:43: "class concurrent_queue: public internal::concurrent_queue_base_v3 {"
concurrent_queue.h:166: "class concurrent_bounded_queue: public internal::concurrent_queue_base_v3"
So both non-bounded and bounded derive from internal::concurrent_queue_base_v3, which has the problematic code that I quoted earlier.
0 Kudos
Dmitry_Vyukov
Valued Contributor I
210 Views
There is 2 different concurrent_queue_base_v3. One of which has the following implementation:

void concurrent_queue_base_v3::internal_push( const void* src ) {
concurrent_queue_rep& r = *my_rep;
ticket k = r.tail_counter++;
r.choose(k).push( src, k, *this );
}

0 Kudos
RafSchietekat
Valued Contributor III
210 Views
"There is 2 different concurrent_queue_base_v3."
I have no words...
0 Kudos
Andrey_Marochko
New Contributor III
210 Views
They are defined in different namespaces: tbb::internal and tbb::strict_ppl::internal. :)

0 Kudos
Reply