<?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 VML crash when calling custom DLL from multiple threads on Windows 7 x64 in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/VML-crash-when-calling-custom-DLL-from-multiple-threads-on/m-p/822479#M4904</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Im encountering crashes when calling MKL Vector Math
Library (VML) functions in a custom DLL from a multithreaded C# program on 64-bit
Windows 7.&lt;/P&gt;

&lt;P&gt;The crash occurs when
calling vsAdd, but not when calling cblas_saxpy, and only occurs
when calling into a custom DLL (built using the makefile in the MKL builder
directory). Calling mkl_rt.dll works ok. Using more than 1 thread is necessary to cause the crash, and it is not entirely deterministic. &lt;/P&gt;&lt;P&gt;I have put together
a small, self-contained test-case to demonstrate the problem: In the attached ZIP archive, youll find two
Windows batch files and a C# source file.
Execute the batch files to build the custom DLL and 4 different
programs, each for a slight variation of the test case (you may need to adjust
the paths in the batch files and in the C# source file: I'm using MKL 10.3 update 6 installed
in the default directory on Win 7 x64). &lt;/P&gt;&lt;P&gt;Run each of the four generated test-*.exe programs. On my system, 3 of the 4 execute
and quit cleanly without errors. However
test-custom-vml.exe will crash about 75% of the time. As you can see by inspecting the C# source
and the batch files, the only difference among the 4 is in which MKL function is called
(vsAdd vs cblas_saxpy) and whether the function resides in mkl_rt.dll or mkl_custom.dll&lt;/P&gt;&lt;P&gt;I've reproduced this problem on a Xeon E5335 system and on a Core i7 970 system, though the crash probability on the Core i7 system is somewhat lower than the Xeon (you'll have to try running it several times). 32-bit DLLs (built with nmake libia32) appear to have the same problem as well. Haven't tried other operating systems.&lt;/P&gt;&lt;P&gt;I'm not experienced with debugging non-managed code, but as best I can tell the problem occurs as the threads are shutting down. Debugging test-custom-vml.exe in Visual Studio 2010 brings up a message about heap corruption.&lt;/P&gt;&lt;P&gt;Any help on how I can get the VML to work from the custom DLL would be appreciated. I know the MKL is supposed to be thread-safe, and I'm even calling MKL_Set_Num_Threads(1) at the top of my program, so this crash is confusing.&lt;/P&gt;&lt;P&gt;Thank you in advance for your time.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gabriel&lt;/P&gt;</description>
    <pubDate>Tue, 27 Sep 2011 19:36:12 GMT</pubDate>
    <dc:creator>gabriel_i_r</dc:creator>
    <dc:date>2011-09-27T19:36:12Z</dc:date>
    <item>
      <title>VML crash when calling custom DLL from multiple threads on Windows 7 x64</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/VML-crash-when-calling-custom-DLL-from-multiple-threads-on/m-p/822479#M4904</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Im encountering crashes when calling MKL Vector Math
Library (VML) functions in a custom DLL from a multithreaded C# program on 64-bit
Windows 7.&lt;/P&gt;

&lt;P&gt;The crash occurs when
calling vsAdd, but not when calling cblas_saxpy, and only occurs
when calling into a custom DLL (built using the makefile in the MKL builder
directory). Calling mkl_rt.dll works ok. Using more than 1 thread is necessary to cause the crash, and it is not entirely deterministic. &lt;/P&gt;&lt;P&gt;I have put together
a small, self-contained test-case to demonstrate the problem: In the attached ZIP archive, youll find two
Windows batch files and a C# source file.
Execute the batch files to build the custom DLL and 4 different
programs, each for a slight variation of the test case (you may need to adjust
the paths in the batch files and in the C# source file: I'm using MKL 10.3 update 6 installed
in the default directory on Win 7 x64). &lt;/P&gt;&lt;P&gt;Run each of the four generated test-*.exe programs. On my system, 3 of the 4 execute
and quit cleanly without errors. However
test-custom-vml.exe will crash about 75% of the time. As you can see by inspecting the C# source
and the batch files, the only difference among the 4 is in which MKL function is called
(vsAdd vs cblas_saxpy) and whether the function resides in mkl_rt.dll or mkl_custom.dll&lt;/P&gt;&lt;P&gt;I've reproduced this problem on a Xeon E5335 system and on a Core i7 970 system, though the crash probability on the Core i7 system is somewhat lower than the Xeon (you'll have to try running it several times). 32-bit DLLs (built with nmake libia32) appear to have the same problem as well. Haven't tried other operating systems.&lt;/P&gt;&lt;P&gt;I'm not experienced with debugging non-managed code, but as best I can tell the problem occurs as the threads are shutting down. Debugging test-custom-vml.exe in Visual Studio 2010 brings up a message about heap corruption.&lt;/P&gt;&lt;P&gt;Any help on how I can get the VML to work from the custom DLL would be appreciated. I know the MKL is supposed to be thread-safe, and I'm even calling MKL_Set_Num_Threads(1) at the top of my program, so this crash is confusing.&lt;/P&gt;&lt;P&gt;Thank you in advance for your time.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gabriel&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2011 19:36:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/VML-crash-when-calling-custom-DLL-from-multiple-threads-on/m-p/822479#M4904</guid>
      <dc:creator>gabriel_i_r</dc:creator>
      <dc:date>2011-09-27T19:36:12Z</dc:date>
    </item>
    <item>
      <title>VML crash when calling custom DLL from multiple threads on Wind</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/VML-crash-when-calling-custom-DLL-from-multiple-threads-on/m-p/822480#M4905</link>
      <description>Gabriel, thanks for the issue - we will check how it works on our side and will back soon.</description>
      <pubDate>Wed, 28 Sep 2011 05:57:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/VML-crash-when-calling-custom-DLL-from-multiple-threads-on/m-p/822480#M4905</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2011-09-28T05:57:13Z</dc:date>
    </item>
    <item>
      <title>VML crash when calling custom DLL from multiple threads on Wind</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/VML-crash-when-calling-custom-DLL-from-multiple-threads-on/m-p/822481#M4906</link>
      <description>&lt;DIV id="_mcePaste"&gt;The problem has been reproduced on our side to.The root cause investigation of the problem is ongoing.&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 28 Sep 2011 12:52:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/VML-crash-when-calling-custom-DLL-from-multiple-threads-on/m-p/822481#M4906</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2011-09-28T12:52:57Z</dc:date>
    </item>
  </channel>
</rss>

