<?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 Hi Jim and Steve, thank you in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987420#M101012</link>
    <description>&lt;P&gt;Hi Jim and Steve, thank you for replying&lt;/P&gt;
&lt;P&gt;Jim: No, none of the variables Offset, POffset, A or B are dummy variables or pointers.&lt;/P&gt;
&lt;P&gt;Steve: By "mismatch" I mean the first write statement produces:&lt;/P&gt;
&lt;P&gt;A 1.00000 -4.00000 3.00000&lt;/P&gt;
&lt;P&gt;and the second produces&lt;/P&gt;
&lt;P&gt;B 0.0000 0.00000 3.00000&lt;/P&gt;
&lt;P&gt;Those aren't the exact results, (I don't have them in front of me now) but that is the pattern: the two lines don't produce the same numbers. For some reason the first and second entries of the array are getting set to zero. It seems to me the only possibility is stack corruption earlier in the routine.&lt;/P&gt;
&lt;P&gt;I haven't been able to reduce the routine yet to something that is tractable in size, and I didn't want to burden anyone with trying to sort through and compile my code, I was just hoping that somewhere someone had assembled a nice guide to debugging stack/heap corruption. I think in my case it is heap corruption because I have a lot of allocatable arrays and type definitions in modules and I use pointers a lot.&lt;/P&gt;
&lt;P&gt;One final note, I don't get the problem when I compile on windows (I use Microsoft Visual Studio) and I'm pretty new to compiling on Linux and am not very familiar with gdb.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Sep 2013 03:12:53 GMT</pubDate>
    <dc:creator>nbunderson</dc:creator>
    <dc:date>2013-09-04T03:12:53Z</dc:date>
    <item>
      <title>Stack corruption debugging tips</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987416#M101008</link>
      <description>&lt;P&gt;I need help debugging stack/heap corruption problems. I have the following code&lt;/P&gt;
&lt;P&gt;real(kind=8) &amp;nbsp; &amp;nbsp;:: Offset(1,3), POffset(1,3), A(3,4), B(3,4)&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;do ii = 1,3&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Offset(1,ii) = (sum(A(ii,:))/8.d0 -&amp;nbsp;sum(B(ii,:)))/8.d0&lt;BR /&gt;enddo&lt;BR /&gt; write(*,*)'A',offset&lt;BR /&gt; do ii = 1,3&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Offset(1,ii) = (sum(A(ii,:))-sum(B(ii,:)))/8.d0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; POffset(1,ii) = (sum(A(ii,:))+sum(B(ii,:)))/8.d0&lt;BR /&gt; enddo&lt;BR /&gt; write(*,*)'B',offset&lt;/P&gt;
&lt;P&gt;There is a lot of other stuff happening in the subroutine before that block of code i've written here but that is where the bug I have is currently manifesting itself as a mismatch in the two write statements. Strange things happen of course: If I add a third write statement within the second loop then the first two write statements will match. If i delete the underlined line of code then the write statements match. Could someone point me in the right direction to debug this kind of error (online tutorial/guide etc)?&amp;nbsp;It's pretty clear that the problem is not in those lines of code. So somewhere above the stack must have been corrupted? I am at a loss as to how to debug this. I've been programming Fortran for years and, embarrassingly I still don't know how to debug this kind of bug. &amp;nbsp;I'm using the compiler on a 32 bit linux machine.&lt;/P&gt;
&lt;P&gt;Nate&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Aug 2013 20:10:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987416#M101008</guid>
      <dc:creator>nbunderson</dc:creator>
      <dc:date>2013-08-31T20:10:20Z</dc:date>
    </item>
    <item>
      <title>so i typed it in the forum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987417#M101009</link>
      <description>&lt;P&gt;so i typed it in the forum slightly wrong. my problem is with the following code...&lt;/P&gt;
&lt;P&gt;do ii = 1,3&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Offset(1,ii) = (&lt;STRONG&gt;sum(A(ii,:))&lt;/STRONG&gt; -&amp;nbsp;sum(B(ii,:)))/8.d0&lt;BR /&gt;enddo&lt;BR /&gt;write(*,*)'A',offset&lt;BR /&gt;do ii = 1,3&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Offset(1,ii) = (sum(A(ii,:))-sum(B(ii,:)))/8.d0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; POffset(1,ii) = (sum(A(ii,:))+sum(B(ii,:)))/8.d0&lt;BR /&gt;enddo&lt;BR /&gt;write(*,*)'B',offset&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Aug 2013 20:23:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987417#M101009</guid>
      <dc:creator>nbunderson</dc:creator>
      <dc:date>2013-08-31T20:23:56Z</dc:date>
    </item>
    <item>
      <title>It is likely that the problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987418#M101010</link>
      <description>&lt;P&gt;It is likely that the problem happens elsewhere in your code. Only a complete reproducible test case would be helpful here.&lt;/P&gt;
&lt;P&gt;What do you mean by "a mismatch"? What makes you think it is stack corruption? There is a run-time stack check option that might help if that is the case.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Sep 2013 23:10:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987418#M101010</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-09-01T23:10:09Z</dc:date>
    </item>
    <item>
      <title>Are Offset and/or POffset</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987419#M101011</link>
      <description>&lt;P&gt;Are Offset and/or POffset DUMMY or pointer?&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 02:35:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987419#M101011</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2013-09-04T02:35:31Z</dc:date>
    </item>
    <item>
      <title>Hi Jim and Steve, thank you</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987420#M101012</link>
      <description>&lt;P&gt;Hi Jim and Steve, thank you for replying&lt;/P&gt;
&lt;P&gt;Jim: No, none of the variables Offset, POffset, A or B are dummy variables or pointers.&lt;/P&gt;
&lt;P&gt;Steve: By "mismatch" I mean the first write statement produces:&lt;/P&gt;
&lt;P&gt;A 1.00000 -4.00000 3.00000&lt;/P&gt;
&lt;P&gt;and the second produces&lt;/P&gt;
&lt;P&gt;B 0.0000 0.00000 3.00000&lt;/P&gt;
&lt;P&gt;Those aren't the exact results, (I don't have them in front of me now) but that is the pattern: the two lines don't produce the same numbers. For some reason the first and second entries of the array are getting set to zero. It seems to me the only possibility is stack corruption earlier in the routine.&lt;/P&gt;
&lt;P&gt;I haven't been able to reduce the routine yet to something that is tractable in size, and I didn't want to burden anyone with trying to sort through and compile my code, I was just hoping that somewhere someone had assembled a nice guide to debugging stack/heap corruption. I think in my case it is heap corruption because I have a lot of allocatable arrays and type definitions in modules and I use pointers a lot.&lt;/P&gt;
&lt;P&gt;One final note, I don't get the problem when I compile on windows (I use Microsoft Visual Studio) and I'm pretty new to compiling on Linux and am not very familiar with gdb.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 03:12:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987420#M101012</guid>
      <dc:creator>nbunderson</dc:creator>
      <dc:date>2013-09-04T03:12:53Z</dc:date>
    </item>
    <item>
      <title>More likely you have either</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987421#M101013</link>
      <description>&lt;P&gt;More likely you have either an uninitialized variable, an out of bounds access or a type mismatch. If you are on Linux, the chance of stack corruption is lower than on Windows (with the STDCALL mechanism there.)&lt;/P&gt;
&lt;P&gt;Since you have both good and bad versions, what I usually do is either run them in the debugger and stop periodically to see where results diverge, or add "instrumentation" (print statements) to write out intermediate calculations and see what is different.&lt;/P&gt;
&lt;P&gt;I am going to move this thread to our Linux Fortran forum.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 13:56:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-corruption-debugging-tips/m-p/987421#M101013</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-09-04T13:56:37Z</dc:date>
    </item>
  </channel>
</rss>

