Application crashes: OMP: Error #136: Cannot create thread.

Application crashes: OMP: Error #136: Cannot create thread.

Bild des Benutzers Ying H (Intel)

It was move from IPP forum. http://redfort-software.intel.com/en-us/forums/showthread.php?t=106951

I have two Windows 7 SP1 x64 dev machines that have reliability problems unless I set KMP_ALL_THREADS environment variable. If I don't set that environment variable, I get application crashes in Windows save (as) file dialogs. When the app crashes, it pops a separate console window to display errors. The errors I see are like this:

    OMP: Error #136: Cannot create thread.

    OMP: System error #8: Not enough storage is available to process this command.

And then the application crashes. The applications that have crashed like this are Outlook Express, VirtualDub, Visual Studio 2010, and a tiny C++ test ui I wrote that just opens a file save dialog. These machines both have 8GB of RAM, I am not low on RAM according to task manager. I have generally had only Visual Studio running.

When I execute the test ui and point to a directory without a jpeg, it works fine. When I point to a directory with a jpeg (as the above steps do), it crashes and pops a console window with this:

    OMP: Error #136: Cannot create thread.

    OMP: System error #8: Not enough storage is available to process this command.

    OMP: Error #178: Function GetExitCodeThread() failed:

    OMP: System error #6: The handle is invalid.

When I run under the visual studio debugger I don't get the crash.

The crash is perfectly repeatable, I haven't seen it not crash given the specified run conditions.

If I set the system environment variable KMP_ALL_THREADS (I tried 0,1,16 and 4096) or OMP_THREAD_LIMIT the crash does not happen. With system environment variable OMP_NUM_THREADS set to 1 or 16 the crash still happens. With system environment variable KMP_STACKSIZE and/or OMP_STACKSIZE set to 4m the crash still happens.

But when I set KMP_ALL_THREADS to 1, 16, or 4096 (probably anything) I get this when I run another app that uses IPP:

    OMP: Warning #96: Cannot form a team with 8 threads, using 1 instead.

    OMP: Hint: Consider unsetting KMP_ALL_THREADS and OMP_THREAD_LIMIT (if either is set).

So I either have crashes and a console window with errors with windows file save as dialog, or a console window with errors on an app that uses IPP. Neither is good.

What is going on here? Is Windows using Intel OMP? What does "not enough storage" mean if I'm not low on memory or disk? Why can it not form a team of 8 threads with KMP_ALL_THREADS set to 4096?

25 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers RyanS

Some of your questions indicate that you didn't notice this sentence: "The applications that have crashed like this are (Microsoft) Outlook Express, VirtualDub, (Microsoft) Visual Studio 2010, and a tiny C++ test ui I wrote that just opens a file save dialog."

All of these programs are 32-bit, I think.
I don't know that any of these applications are using IPP. However they appear to be using Intel OpenMP because the crash is affected by an Intel-specific environment variable KMP_ALL_THREADS. Is it correct that KMP_ALL_THREADS is Intel-specific?

So it is like the Windows operating system itself has the problem, not any particular application.

One PC is Nehalem and the other is Ivy Bridge. They have different motherboards. So I don't think hardware is the issue.

Bild des Benutzers Ying H (Intel)

Application crashes: OMP: Error #136: Cannot create thread.
Hi Ryans,

No, we notice the scenario you mentioned.  (none of the apllication  Outlook Express, VirtualDub, (Microsoft) Visual Studio 2010, and a tiny C++ test ui use IPP, so it should not related to IPP). But as you post the problem to IPP forum, so we need to make sure if it is IPP-related or Intel Compiler related. 

But you should be right about KMP_ALL_THREADS is Intel-specific. So the problem appear to be related Intel OpenMP.  
As Sergery mentioned, it is impossible to catch the reason without a test case, you may do general check, like check how many threads started in task manager etc.

( i may try to move your post to Intel Compiler forum and see if there are some insight from Compiler experts)
the new post in Intel Compiler Forum is http://redfort-software.intel.com/en-us/forums/showthread.php?t=107255

Best Regards,
Ying

Bild des Benutzers Sergey Kostrov
Quoting Ying H (Intel) ...When the app crashes, it pops a separate console window to display errors. The errors I see are like this:
    OMP: Error #136: Cannot create thread.
    OMP: System error #8: Not enough storage is available to process this command.
...

Some time ago I had a similar problem with a stress test-case ( based on TBB library ) and it was creating hundreds of threads.
In order to create as many as possible threads I used the following settings for the linker:

...
#pragma message ( "*** New HEAP Commit:Reserve and STACK Commit:Reserve Values Defined ***" )

#ifdef _DEBUG
     // Case 1
// #pragma comment( linker, "/HEAP:1069547520,1069547520" )
// #pragma comment( linker, "/STACK:4194304,4194304" )

     // Case 2
// #pragma comment( linker, "/HEAP:134217728,134217728" )
// #pragma comment( linker, "/STACK:134217728,134217728" )

     // Case 3
// #pragma comment( linker, "/HEAP:268435456,268435456" )
// #pragma comment( linker, "/STACK:268435456,268435456" )

     // Case 4
     #pragma comment( linker, "/HEAP:536870912,536870912" )
     #pragma comment( linker, "/STACK:536870912,536870912" )
#endif

#ifdef NDEBUG
     // Case 1
// #pragma comment( linker, "/HEAP:1069547520,1069547520" )
// #pragma comment( linker, "/STACK:4194304,4194304" )

     // Case 2
// #pragma comment( linker, "/HEAP:134217728,134217728" )
// #pragma comment( linker, "/STACK:134217728,134217728" )

     // Case 3
// #pragma comment( linker, "/HEAP:268435456,268435456" )
// #pragma comment( linker, "/STACK:268435456,268435456" )

     // Case 4
     #pragma comment( linker, "/HEAP:536870912,536870912" )
     #pragma comment( linker, "/STACK:536870912,536870912" )
#endif
...

All my tests were done on a 32-bit Windows XP.

Best regards,
Sergey

Bild des Benutzers Sergey Kostrov
I'd like to answer some of questions asked by Rayn.

Quoting Ying H (Intel) What is going on here?

     [SergeyK] It looks like some problem with memory allocation. However, it is not clear why some 3rd party applications crashed.

Is Windows using Intel OMP?

     [SergeyK] No. Microsoft has its own version of OpenMP.

What does "not enough storage" mean if I'm not low on memory or disk?

     [SergeyK] When Windows creates a thread it needs some memory to create a stack. If there is no more memory
                        available Windows doesn't create a thread and a user application could crash if there is no an error processing.

                        Error #136 is returned by from OpenMP library
                        System Error #8 is returned from a 'GetLastErrorWin32 API function

Why can it not form a team of 8 threads with KMP_ALL_THREADS set to 4096?

     [SergeyK] With Intel OpenMP library you should be able to do it.

 

Bild des Benutzers Sergey Kostrov
Hi Ryan,

Quoting Sergey Kostrov ...Why can it not form a team of 8 threads with KMP_ALL_THREADS set to 4096?

     [SergeyK] With Intel OpenMP library you should be able to do it. 

Here is a link to a thread:

     Stress testing of Intel OpenMP library - More than 18,600 OpenMP threads created in a parallel region
     http://redfort-software.intel.com/en-us/forums/showthread.php?t=105139&o=a&s=lr

Please take a look.

Best regards,
Sergey

Bild des Benutzers Jennifer J. (Intel)

Can you upload the program that is built with Intel C++ compiler or using the IPP libs?  Also how you build and run. 
do you have other versions of Intel C++ Compiler installed or IPP installed? make sure the correction openmp dll are use (the path should point to the correct openmp directory).

Jennifer

Bild des Benutzers RyanS

Some of the comments seem to misunderstand the problem. Note this sentence: "The applications that have crashed like this are (Microsoft) Outlook Express, VirtualDub, (Microsoft) Visual Studio 2010, and a tiny C++ test ui I wrote that just opens a file save dialog."

The C++ tiny test UI I wrote doesn't use IPP, it just opens the Windows file save dialog. I am not using the Intel C++ compiler for my test UI, nor is it likely that the other affected applications use it. I do not own the Intel C++ compiler, however I see various Intel products have been installed possibly as part of the IPP installation or the Intel Media SDK installation.

I am not sure how to check which openmp dll would be used. I have not done OpenMP development before. From an internet search, I see mention of "vcomp.dll" but that is not in my path.

Bild des Benutzers Tim Prince

If you include objects built with CL /openmp in your build which also uses ICL or ifort , your link step must be set up so as to use
-defaultlib:libiomp5md.lib
-nodefaultlib:vcomp.lib
-nodefaultlib:vcompd.lib
This should happen automatically if you use the Intel compiler with option /Qopenmp for the link step.
I'm confused about what all is asked in this thread, but I'm answering the part about choosing the correct OpenMP support version, without knowing whether it's relevant to the other questions.
You can verify the OpenMP libraries, e.g. by "dumpbin /dependents your.exe" :
...
File Type: EXECUTABLE IMAGE

Image has the following dependencies:

libiomp5md.dll
KERNEL32.dll
imagehlp.dll

That is, you must not see either of the vcomp .dll when you are using an Intel compiler, even though part of your build is done by CL.

Bild des Benutzers RyanS

Thanks for the suggestions. dumpbin /dependents gives: user32.dll, comdlg32.dll, msvcr100d.dll, and kernel32.dll (for the debug build).
I also tried Dependency Walker. Depends.exe did not show a dependency on libiomp*.dll, nor vcomp.dll. I tried to "profile" using depends.exe but it hung, regardless of settings.
So I am still unable to tell why my trivial windows exe is failing with an OpenMP problem that depends on Intel-specific environment variables.

Bild des Benutzers Sergey Kostrov

>>...So I am still unable to tell why my trivial windows exe is failing with an OpenMP problem that depends on Intel-specific environment variables...

Hi,

Could you upload a VS project that reproduces the problem? If there are some proprietery pieces of codes in your "trivial application" you could remove them.

Best regards,
Sergey

Bild des Benutzers RyanS

Because of the list of applications that crash ((Microsoft) Outlook Express, VirtualDub, (Microsoft) Visual Studio 2010, and my tiny ui) I have concluded that this is a platform problem, and that it doesn't have anything to do with my source code.

The trivial windows exe is just the default windows app that visual studio creates for you when you create a new Windows GUI project, and then I took over the Help->About menu item and opened a Windows Save File Dialog instead. There is no proprietary code, nor is there anything that is likely to help this investigation, except an easy way to pop a Windows Save File Dialog. But I will upload it anyway.

This is a platform problem. The Windows Save File Dialog is crashing when pointed to a directory with a jpeg in it. And the crash depends on an Intel-specific OpenMP environment variable.

Anlagen: 

AnhangGröße
Herunterladen testsaveasdialog.zip29.48 KB
Bild des Benutzers RyanS

Per Ying's suggestion on the original thread, I ran with KMP_AFFINITY=verbose.

Here is the output:
OMP: Info #204: KMP_AFFINITY: decoding x2APIC ids.
OMP: Info #202: KMP_AFFINITY: Affinity capable, using global cpuid leaf 11 info
OMP: Info #154: KMP_AFFINITY: Initial OS proc set respected: {0,1,2,3,4,5,6,7}
OMP: Info #156: KMP_AFFINITY: 8 available OS procs
OMP: Info #157: KMP_AFFINITY: Uniform topology
OMP: Info #179: KMP_AFFINITY: 1 packages x 4 cores/pkg x 2 threads/core (4 total cores)
OMP: Info #147: KMP_AFFINITY: Internal thread 0 bound to OS proc set {0,1,2,3,4,5,6,7}
OMP: Info #147: KMP_AFFINITY: Internal thread 1 bound to OS proc set {0,1,2,3,4,5,6,7}
OMP: Info #147: KMP_AFFINITY: Internal thread 2 bound to OS proc set {0,1,2,3,4,5,6,7}
OMP: Info #147: KMP_AFFINITY: Internal thread 8 bound to OS proc set {0,1,2,3,4,5,6,7}
..

And then several hundred more of these (up to thread numbers over 500) and then crashes with the errors I listed in my original post.

Bild des Benutzers Sergey Kostrov

>>...There is no proprietary code, nor is there anything that is likely to help this investigation, except an easy way to pop a Windows Save File
>>Dialog. But I will upload it anyway...
>>...
Thank you. I'll take a look at your VS 2010 project. By the way, did you try to verify dependencies ( with MS Depends utility ) of your test application as soon as it is built?
Best regards,
Sergey

Bild des Benutzers RyanS

Yes, in my post of 9/17 I was working with a fresh build.

Bild des Benutzers Sergey Kostrov

>>...There is no proprietary code, nor is there anything that is likely to help this investigation, except an easy way to pop a Windows Save File
>>Dialog. But I will upload it anyway...
>>...
.
I tested your project and I didn't have any problems. When I selected 'About' menu item the test application opened the 'Save File' dialog, then I selected some file ( under debugger I checked that everything was right ) and then selected 'Exit' menu irem. So, No problems at all. Could you upload a file that is located at a path:
.
. Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"
.
I'm interested to look at 'Microsoft.Cpp.Default.props' file. Thanks in advance.
Best regards,
Sergey

Bild des Benutzers RyanS

Thanks for your effort. It is not likely that you will repro my crash, or you probably would have seen it yourself before, since it it not only caused by my test program.
I noticed you didn't mention pointing the save dialog to a folder with a jpeg in it, so you may have missed that detail in the repro steps.
I will upload the props file. Can I ask what you are looking for? Note that since this crash affects other programs not compiled on my machine, it is unlikely that my compiler or build configuration is related.

Anlagen: 

Bild des Benutzers Ying H (Intel)

Hi Ryan
Agree with you, it should be nothing to do with your code and exe. I just tried your code. It can run without any problem when point to a directory with a jpeg in it. and no any KMP information to show up. (as the exe or my file system doesn't trigger the openm program.) So

This is your platform problem. The Windows Save File Dialog is crashing when pointed to a directory with a jpeg in it. And the crash depends on an Intel-specific OpenMP environment variable.

The key questionare
1) which application call the libiomp5md.dll on your machine? Could you please search in your machine and see where are the libiomp5md.dll located besides IPP (intel composer XE folder, or if only in IPP folder, you can rename them and see your exe's behavious)
not sure if you have tried it before. please set KMP_VERISON=1 and run your exe to see the library version information, and compare with the openmp dll on your machine?

2) It seems jpeg folder should trigger the application which have OpenMP library call. which default program are set for open a jpeg file? for exmaple, my system use windows Photo viewer.

Best Regards,
Ying

Bild des Benutzers Sergey Kostrov

Hi Ryan,

>>...I noticed you didn't mention pointing the save dialog to a folder with a jpeg in it, so you may have missed that detail in the repro steps.
.
I did it. Sorry for not mentioning it.
.
>>...I will upload the props file. ..
.
Thank you and I'll take a look.
.
Ryan, could you reproduce your problem in Debug configuration of your test project? I'd like to see a complete output from 'Output' window of a Visual Studio. Let me know if you need some help.
.
Best regards,
Sergey

Bild des Benutzers Sergey Kostrov

This is a short follow up...
.
>>>>...I will upload the props file. ..
>>.
>>Thank you and I'll take a look.
.
Hi Ryan, I did not find any problems with the props file. As I already mentioned "...I'd like to see a complete output from 'Output' window of a Visual Studio..."
Best regards,
Sergey

Bild des Benutzers RyanS

Thanks Ying for pointing the right direction. The problem was that I have a windows installer that installs UIC dll's. The install builder automatically decided to register wic_uic_codec.dll with COM. So when Windows opened a save dialog on a folder with a jpeg, it was using that UIC dll (for a thumbnail, or just properties or something) and some of the other UIC dll's also (because when I deleted the other dll's the problem went away). The UIC dlls use Intel OpenMP, and somewhere there is a bug or maybe a version incompatibility or maybe something about the COM registration was wrong. I did not nail down the root cause nor try the newer versions of UIC dll's. The UIC dll's are the Intel-built ones and are from version 7.0.7. I told the installer not to register that UIC DLL and that solves my problem.

Bild des Benutzers Sergey Kostrov

>>...UIC dll's also (because when I deleted the other dll's the problem went away...
.
Thanks for the update! By the way, you could simply unregester a COM dll by executing a command 'regsvr32 /u [DllName.dll]'. Try to execute 'regsvr32 /?' in order to see all command line options.

Bild des Benutzers Sergey Kostrov

>>...The UIC dlls use Intel OpenMP...
.
Did you use MS Depends to see a complete list of dependent Dlls? A problem could be related to an Intel C-runtime library instead.

Bild des Benutzers Sergey Kostrov

>>...I'd like to see a complete output from 'Output' window of a Visual Studio...
.
I actually wanted to see something like that:
.
[Output]
[ Combobox: Show output from: Debug ]
...
'TestAppD.exe': Loaded 'C:\WorkEnv\AppsWorkDev\AppsSca\TestApp\Debug\TestAppD.exe', Symbols loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\user32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugMFC_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_a0fb332d\mfc80ud.dll', No symbols loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_d014c028\msvcr80d.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\oleacc.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\winspool.drv', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\comdlg32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', Exports loaded.
'TestAppD.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFCLOC_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_6a5bb789\mfc80ENU.dll', Binary was not built with debug information.
'TestAppD.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll', Exports loaded.
The program '[1908] TestAppD.exe: Native' has exited with code 0 (0x0).
.
In your case exports for 'wic_uic_codec.dll' would be loaded if it was build with Debug information.

Bild des Benutzers Sergey Kostrov

>>...I'd like to see a complete output from 'Output' window of a Visual Studio...
.
Take into account that VS also shows the list of unloaded modules ( DLLs ). It looks like:
...
Unload module: msvcr80d.dll
Unload module: commctrl.dll
...
The program '[370868a6] TestAppD.exe' has exited with code 0 (0x0).

Melden Sie sich an, um einen Kommentar zu hinterlassen.