<?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 Managed Debugging Assistant PInvokeStackImbalance in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771878#M22993</link>
    <description>Here's a test case that reproduces the error.&lt;BR /&gt;&lt;BR /&gt;Charlie</description>
    <pubDate>Mon, 06 Dec 2010 22:59:36 GMT</pubDate>
    <dc:creator>CharlieG</dc:creator>
    <dc:date>2010-12-06T22:59:36Z</dc:date>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771872#M22987</link>
      <description>I'm starting to use Visual Studio 2010 and Intel Visual Fortran Composer XE 2011 on an existing code base. I'm getting an error that I haven't seen before:&lt;BR /&gt;&lt;BR /&gt;Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in '...\\FCCMod.exe'. Additional Information: A call to PInvoke function 'FCCMod!FCCMod.clsFCCDll::FCCMod' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanged signature.&lt;BR /&gt;&lt;BR /&gt;Seems like they're trying to tell me what the problem is but I'm not a knowledgable enough programmer to understand the message. If anyone could help me out I'd appreciate it.&lt;BR /&gt;&lt;BR /&gt;My Visual Basic Code:&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Public Class clsFCCDll&lt;/P&gt;&lt;P&gt;'FCC Model connections &lt;/P&gt;&lt;P&gt;Public Declare Sub FCCMod Lib "FCCmod.dll" Alias "FCCMod" (ByVal CommonUserDataPath As String, ByVal ExePath As String)&lt;/P&gt;&lt;P&gt;Public Sub FCCModel(ByVal CommonUserDataPath As String, ByVal ExePath As String)&lt;BR /&gt;&lt;BR /&gt;FCCMod(CommonUserDataPath, ExePath)&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;End Class&lt;BR /&gt;&lt;BR /&gt;My Visual Fortran Code:&lt;/P&gt;&lt;P&gt;!DEC$NOFREEFORM&lt;/P&gt;&lt;P&gt;subroutine FCCMod(strUserAppPath, strExePath)&lt;/P&gt;&lt;P&gt;!DEC$ATTRIBUTES ALIAS:'FCCMod'::FCCMod&lt;/P&gt;&lt;P&gt;!DEC$ATTRIBUTES DLLEXPORT :: FCCMod&lt;/P&gt;&lt;P&gt;use IFCOM&lt;/P&gt;&lt;P&gt;use IFCOMTY&lt;/P&gt;&lt;P&gt;use IFWIN&lt;/P&gt;&lt;P&gt;CHARACTER(256), INTENT(IN) :: strUserAppPath&lt;/P&gt;&lt;P&gt;!DEC$ ATTRIBUTES REFERENCE :: strUserAppPath&lt;/P&gt;&lt;P&gt;CHARACTER(256), INTENT(IN) :: strExePath&lt;/P&gt;&lt;P&gt;!DEC$ ATTRIBUTES REFERENCE :: strExePath&lt;/P&gt;&lt;P&gt;status = AllocConsole()&lt;/P&gt;&lt;P&gt;ILEN = INDEX(strUserAppPath,CHAR(0)) - 1&lt;/P&gt;&lt;P&gt;UserAppPath = strUserAppPath(1:ILEN)&lt;/P&gt;&lt;P&gt;ILEN = INDEX(strExePath,CHAR(0)) - 1&lt;/P&gt;&lt;P&gt;ExePath = strExePath(1:ILEN)&lt;BR /&gt;&lt;BR /&gt;And much more...&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 16:30:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771872#M22987</guid>
      <dc:creator>CharlieG</dc:creator>
      <dc:date>2010-12-03T16:30:57Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771873#M22988</link>
      <description>One change in the Intel Visual Fortran Compiler 2011 is that strings are no longer null terminated (they were by chance in previous releases). Fortran expects this, but Basic does not generate null terminated strings so you may need to add null at the end of strings you are passing to Fortran.&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;------&lt;/P&gt;&lt;P&gt;Wendy&lt;/P&gt;&lt;P&gt;&lt;A href="http://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/announcement/241/"&gt;Attaching or including files in a post&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 20:58:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771873#M22988</guid>
      <dc:creator>Wendy_Doerner__Intel</dc:creator>
      <dc:date>2010-12-03T20:58:29Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771874#M22989</link>
      <description>I tried concatenating a CHR(0) to the end of my strings in VB before passing them to Fortran but it did not fix the error.</description>
      <pubDate>Mon, 06 Dec 2010 15:08:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771874#M22989</guid>
      <dc:creator>CharlieG</dc:creator>
      <dc:date>2010-12-06T15:08:38Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771875#M22990</link>
      <description>&amp;gt; strings are no longer null terminated (they were by chance in previous releases). Fortran expects this&lt;BR /&gt;&lt;BR /&gt;Can you please elaborate on this? As I understood, it's the other way round, older versions zero-padded the Fortran strings so passing them to C-style routines wasworking (by accident), but the 12.x release may not "terminate" the Fortran string with a zero character so requires user interaction.&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Dec 2010 15:57:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771875#M22990</guid>
      <dc:creator>strohhaecker</dc:creator>
      <dc:date>2010-12-06T15:57:45Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771876#M22991</link>
      <description>There was a case where a user program was relying on a character variable being followed by a NUL, which sometimes was the case in version 11.1 but much less so in version 12. However, I don't think VB uses NUL-terminated strings. Either it passes a BSTRING descriptor (which requires calling routines to create and read in Fortran) or it passes just the data with no length.</description>
      <pubDate>Mon, 06 Dec 2010 18:55:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771876#M22991</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-12-06T18:55:23Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771877#M22992</link>
      <description>I think we would need a reproducing test case or more detail on the error message to give you any more help. It does look like the error message is trying to mark a disconnect between your call to DLL so I would like at the parameters you are passing to see if they are in format your called procedure is expecting.&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;------&lt;/P&gt;&lt;P&gt;Wendy&lt;/P&gt;&lt;P&gt;&lt;A href="http://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/announcement/241/"&gt;Attaching or including files in a post&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2010 22:06:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771877#M22992</guid>
      <dc:creator>Wendy_Doerner__Intel</dc:creator>
      <dc:date>2010-12-06T22:06:31Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771878#M22993</link>
      <description>Here's a test case that reproduces the error.&lt;BR /&gt;&lt;BR /&gt;Charlie</description>
      <pubDate>Mon, 06 Dec 2010 22:59:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771878#M22993</guid>
      <dc:creator>CharlieG</dc:creator>
      <dc:date>2010-12-06T22:59:36Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771879#M22994</link>
      <description>Charlie,&lt;BR /&gt;&lt;BR /&gt;Thanks for posting your code.&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;The unbalanced stack error was caused by the incorrect calling convention of the fortran subroutine.The VB code assumes the subroutine cleans up the stack when returning; however, the default calling convention of Fortran requires the caller clean up the stack. Then the runtime system detected the mis-matched stack pointer before/after the call. To fix this, please&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change the subroutine to STDCALL like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;B&gt;!DEC$ATTRIBUTES DLLEXPORT,STDCALL :: FCCMod&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference:&lt;BR /&gt;&lt;A href="http://support.microsoft.com/kb/153586 "&gt;&lt;/A&gt;&lt;A href="http://support.microsoft.com/kb/153586" target="_blank"&gt;http://support.microsoft.com/kb/153586&lt;/A&gt;&lt;BR /&gt;The &lt;A href="http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/win/compiler_f/bldaps_for/common/bldaps_summlang.htm"&gt;Mixed Language section of the IntelVIsual Compiler documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;------&lt;/P&gt;&lt;P&gt;Wendy&lt;/P&gt;&lt;P&gt;&lt;A href="http://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/announcement/241/"&gt;Attaching or including files in a post&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2010 17:03:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771879#M22994</guid>
      <dc:creator>Wendy_Doerner__Intel</dc:creator>
      <dc:date>2010-12-07T17:03:42Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771880#M22995</link>
      <description>That did it. Thanks for the help.</description>
      <pubDate>Tue, 07 Dec 2010 17:27:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771880#M22995</guid>
      <dc:creator>CharlieG</dc:creator>
      <dc:date>2010-12-07T17:27:12Z</dc:date>
    </item>
    <item>
      <title>Managed Debugging Assistant PInvokeStackImbalance</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771881#M22996</link>
      <description>Had the same problem with WPF and a Fortran DLL.&lt;BR /&gt;&lt;BR /&gt;That didnt happen with Windows Forms and the same DLL though...&lt;BR /&gt;&lt;BR /&gt;Now I will have a nice weekend :-)&lt;BR /&gt;&lt;BR /&gt;Markus</description>
      <pubDate>Fri, 27 Apr 2012 13:17:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Managed-Debugging-Assistant-PInvokeStackImbalance/m-p/771881#M22996</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2012-04-27T13:17:50Z</dc:date>
    </item>
  </channel>
</rss>

