I am running into a problem where I get the following error
Assertion t->state()==task::allocated failed on line 544 of file ../../src/tbb/scheduler.cpp
Detailed description: attempt to spawn task that is not in 'allocated' state
My application starts of by spawning a root task and setting it's ref-count to 1, which creates other tasks. All the tasks are stored in a task-pool which is a TBB concurrent_hash_map. The non-root tasks are created using allocate_root and each time it's done, the ref-count of the root is incremented. Each of these non-root tasks do some computation and then send the outputs of that computation to other tasks. Before the output is sent, the task-pool is checked to see it the correct/intended task is available(created using allocate_root). Each of the non-root task is spawned only when all the "inputs" to that task are available and when the execution is done, the ref-count of the root is decremented.
I have checked the task-ID's and task states. I see that for one of the tasks, after it is being created when one of the other tasks tries to spawn it, the state is once 3(tbb:allocated) and either 0 or 2. This is when I get the tbb_assert error. I see that the ref-count of root is correctly incremented/decremented, when the other tasks are created and destroyed.
I was wondering what could be causing this error. Is there a common mistake that I may be making?