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

Hang on initialise

ONEILL__PAUL
Beginner
422 Views
I'm seeing a sporadic hang when my application loads. As far as I can work out the sequence of events is as follows and I was wondering if there is a recommended way to avoid this occuring.

1. App starts
2. It loads dll 'Foo' (no code in dll main)
3. Foo has dependency on bar so it causes dll 'Bar' to load
4. App now calls initialise function in Foo
4.1 Foo's initalise function calls initialise in Bar
4.2 Bar starts a background thread (license check)
4.3 Foo creates tbb::task_scheduler_init, deferred
4.4 Foo calls tbb::task_scheduler_init::initialize(...)
-- hang -- function never returns

This main thread of execution is stuck in tbbmalloc.cpp:144, in a call to LoadLibrary, waiting for the global dll lock. This has the comment line. "Preventing TBB allocator library from unloading to prevent resource leak, as memory is not released on the library unload."

The interesting bit is that the other thread that was fired off by the 'Bar' dll has now got stuck in mallocThreadShutdownNotification, MemoryAllocator.cpp. It has the global dll lock as this was triggered by Dllmain in tbbmalloc.cpp:215 (DLL_THREAD_DETACH), but is not able to get tbb's lock.

Any suggestions, maybe some finer grain control on startup could be useful. For now I think I will just make sure tbb is initialised as early as possible, even if other tasks are unrelated. However this still does not seem like it would entirely prevent this situation, as the dll main events will presumbly start firing as soon as the tbb dll is loaded.

Thanks,
Paul.

0 Kudos
4 Replies
Alexandr_K_Intel1
422 Views
Something similar was fixed in TBB 3.0 Update 1 release. Could you please report which TBB versionare you using?
0 Kudos
ONEILL__PAUL
Beginner
422 Views
I am using what i thought to be the latest stable release (tbb30_20100406oss), i am not sure if this includes update 1 or not?

Thanks, Paul
0 Kudos
Alexandr_K_Intel1
422 Views
Update 1 was released on June 16, 2010, so the fix in not in release you are using. Please try "Commercial Aligned Release" from http://www.threadingbuildingblocks.org/file.php?fid=78 , preferably 3.0 update 2.
0 Kudos
ONEILL__PAUL
Beginner
422 Views
thanks for your help.
0 Kudos
Reply