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

tbb::task_scheduler_init --> "__beginthreadex: Invalid argument" (w_tbb_pu_2.1.017)

First off, I love TBB as it gives us tredmenous and easy speed in our applications. That said, we have run into an annoying issue recently that is affecting the stability of our applications.

The error that I've run into quite a few times now (and it is the lead cause of crashes in our application) is this: the __beginthreadex calls that are part of the tbb::task_scheduler_init constructor are failing randomly, less than 1% of the time, but they are failing with the error message "Invalid argument."

We are using the commercial version of TBB and thus I haven't gone through the source to find the issue.

It appears to happen somewhat at random during the execution of our application. We do start and stop TBB fairly regularly as we are operating within the context of another application. I believe it is this starting and stopping of TBB that is causing this issue to appear.

Or alternatively, we are misusing TBB in some way that is leading to intermittent failures. Unfortunately, I am currently at a loss as to the way that we are misusing TBB. If we were misusing TBB, it would be good to have an ASSERT or some other type of checking occuring that would inform us clearly that we are doing something inappropriate with the library.

I am using w_tbb_pu_2.1.017, which is about 1 year old.

Do we know if it is fixed in newer versions of TBB or what exactly is causing this?

Best regards,
Ben Houston
0 Kudos
1 Reply
New Contributor III
Hello Ben,

Could you please clarify, when you are starting and stopping TBB, do you actually load/unload the TBB DLL? Or do you only create/destroy tbb::task_scheduler_init objects repeatedly?

0 Kudos