<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fatal error exit handler with code 3 after lots of repeated Load+FreeLibrary in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Fatal-error-exit-handler-with-code-3-after-lots-of-repeated-Load/m-p/1391474#M33259</link>
    <description>&lt;P&gt;I've found it!&lt;BR /&gt;&lt;BR /&gt;The problem was that my dll has been using vsExp/vsLn fucntions.&lt;/P&gt;
&lt;P&gt;In that case mkl_finalize() isn't enough. After adding MKLFreeTls( DLL_PROCESS_DETACH ) before mkl_finalize() the code works just fine.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jun 2022 02:17:37 GMT</pubDate>
    <dc:creator>FedericoJuarez</dc:creator>
    <dc:date>2022-06-10T02:17:37Z</dc:date>
    <item>
      <title>Fatal error exit handler with code 3 after lots of repeated Load+FreeLibrary</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Fatal-error-exit-handler-with-code-3-after-lots-of-repeated-Load/m-p/1390669#M33244</link>
      <description>&lt;P&gt;Hi there!&lt;BR /&gt;&lt;BR /&gt;I'm facing the problem with OneMKL2022.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scenario is:&lt;/P&gt;
&lt;P&gt;- Windows&lt;/P&gt;
&lt;P&gt;- 32-bit app&lt;/P&gt;
&lt;P&gt;- mkl_sequential&lt;/P&gt;
&lt;P&gt;- DLL code which does a lot of stuff (including MKL).&lt;/P&gt;
&lt;P&gt;- simple EXE which does&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;int testIter = 0;
while(true) {
    printf("iter #%d\n", ++testIter);
    HMODULE myLib = ::LoadLibrary("MyLib.dll");
    /* get the address of function in .dll and call it */
    ::FreeLibrary(myLib);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem: after 1000+ iterations the MKL fatal error handler is called with code 3 during matrix multiplication (BUT, stack shows mkl_serv_malloc which is called somewhere from cblas_sgemm).&lt;/P&gt;
&lt;P&gt;The `mkl_finalize` is called at the end of the function.&lt;/P&gt;
&lt;P&gt;All the metrics don't show any leaks during running (memory/handles/anything).&lt;/P&gt;
&lt;P&gt;Even my attempts to measure the memory "fragmentation" (finding out the 5 biggest possible memory size, which can be `malloc`'ed), don't show any fragmentation problem (btw, peak memory consumption of app is relatively small ~350 MB).&lt;/P&gt;
&lt;P&gt;One more strange fact: it always fails on the same iteration, on the same `cblas_gemm` call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure that the problem is in MKL, because by this moment I didn't manage to create small clear sample for reproducing this bug (the DLL has a lot of additional code alongside with MKL computation). I'm just kinda lost here, what could be the reason of such behavior? So my questions are:&lt;/P&gt;
&lt;P&gt;1. What is code 3? Are there any docs with these codes because I haven't found one...&lt;/P&gt;
&lt;P&gt;2. Which resource could possibly be leaking (or ran out of)? Because 1000+ iterations show that it isn't a simple 'bug in the code' and it looks like a leak or running out of something.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 17:26:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Fatal-error-exit-handler-with-code-3-after-lots-of-repeated-Load/m-p/1390669#M33244</guid>
      <dc:creator>FedericoJuarez</dc:creator>
      <dc:date>2022-06-07T17:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal error exit handler with code 3 after lots of repeated Load+FreeLibrary</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Fatal-error-exit-handler-with-code-3-after-lots-of-repeated-Load/m-p/1391474#M33259</link>
      <description>&lt;P&gt;I've found it!&lt;BR /&gt;&lt;BR /&gt;The problem was that my dll has been using vsExp/vsLn fucntions.&lt;/P&gt;
&lt;P&gt;In that case mkl_finalize() isn't enough. After adding MKLFreeTls( DLL_PROCESS_DETACH ) before mkl_finalize() the code works just fine.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 02:17:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Fatal-error-exit-handler-with-code-3-after-lots-of-repeated-Load/m-p/1391474#M33259</guid>
      <dc:creator>FedericoJuarez</dc:creator>
      <dc:date>2022-06-10T02:17:37Z</dc:date>
    </item>
  </channel>
</rss>

