I get this strage error when I try to execute a parallel_for from a worker thread. And yes I didcall task_scheduler_init, but from the main thread.
The error is an assertion:
Thread has not activated a task_scheduler_init object?
the assertion is thrown at
task_group_context ( kind_type relation_with_parent = bound )
Was the worker thread created by you (using _beginthreadex, CreateThread, pthread_create or some other API)? If so, then you need to use task_scheduler_init there as well. The common rule is that you need to initialize TBB scheduler in every thread created by yourself (or by OS for you - like the main thread of your app).
Just so that it made more sence, TBB needs to have a separate instance of its scheduler in each thread that works with TBB tasks (or where TBB's parallel algorithms are used). Such a design drastically decreases the amount of costly inter-thread communication. Each thread maintains a local pool of task, and only when it gets empty tries to steal some work from other threads.