Leaked mutant (mutex) handles during formatted write
I'm using the ifort compiler, version 16.0 Build 20150815. In my long-running program (2-3 days) I'm doing quite some formatted writes along the lines of:
CHARACTER(1024) :: c_string
WRITE (c_string, '(2X,A8,I2,F9.1)') parent%sub%c_a_string, parent%sub%i_an_integer, d_a_double
and use the result for output e.g. to the screen.
Every time I'm doing this, a mutant (mutex) handle is leaked.
I used WinDbg's !htrace -diff function to get traces of the incidents. What I get are loads of traces similar to this one:
During the runtime, these leaked mutant handles pile up until they reach the number 16711680. When the program is finally at the point of writing stuff to a file, the attempt to get a file handle fails with the error:
0x000005aa ERROR_NO_SYSTEM_RESOURCES : Insufficient system resources exist to complete the requested service.
(The file is created but the file handle, I get from fopen is NULL)
It seems that the handle leaking is happening inside some Intel libraries. Is this a known problem? Is it maybe fixed in a version later than 16.0? Is there anything I can do to circumvent the handle leaking?
I found something which seems somewhat related, only it's describing memory leaks during using the WRITE function: https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/518269