<div dir="ltr"><div>I've been trying to reproduce this problem with a minimal example with no success for quite some time (spent a large part of my last 2 weekends trying out different things). Perhaps some compiler guru can figure out what is going on :\<br>

<br></div>I did come across this though, which looks to be somewhat related to the problem.<br><br><a href="https://randomascii.wordpress.com/2013/12/01/vc-2013-class-layout-change-and-wasted-space/">https://randomascii.wordpress.com/2013/12/01/vc-2013-class-layout-change-and-wasted-space/</a><br>

</div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">Ho Cheung<br><a href="mailto:hocheung20@gmail.com" target="_blank">hocheung20@gmail.com</a><br>Cell: (775) 388-2368</div></div>
<br><br><div class="gmail_quote">On Sat, Nov 30, 2013 at 8:00 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word">Hello,<div><br></div><div>If you can come up with minimal code to reproduce the MSVC12 bug, then I can report it to them.</div><div><br></div><div>Thanks,</div><div>Brad</div><div><div class="h5">

<div><br><div><div>On Nov 29, 2013, at 3:36 PM, Ho Cheung <<a href="mailto:hocheung20@gmail.com" target="_blank">hocheung20@gmail.com</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr"><div><div><div>Looks like this is compiler bug relating to SSE and alignment. The Win32 and Win64 Debug builds all use the x87 stack so do not experience this issue.<br>

<br></div><div>Here is the assembly code from one of the crashing tests:<br>




</div><div><br>    const SpacingType spacing = outputImage->GetSpacing();<br>000000013FE078C9  mov         rax,qword ptr [rcx]  <br>000000013FE078CC  call        qword ptr [rax+180h]  <br>000000013FE078D2  movaps      xmm0,xmmword ptr [__xmm@3ff00000000000003ff0000000000000 (0140120C10h)]  <br>






<br>    for ( unsigned int i = 0; i < ImageDimension; i++ )<br>      {<br>      coeffs[i] = 1.0 / static_cast< double >( spacing[i] );<br>000000013FE078D9  divpd       xmm0,xmmword ptr [rax] <br><br></div><div>Following it with the debugger, RAX = 0000000002162018 at the divpd instruction.<br>






</div><div><br>The memory operands of divpd must be aligned on 16-byte boundary[1] but as we can see clearly here it is only aligned on 8-byte boundary.<br><br>RAX is last set by the call to GetSpacing (itkGetConstReferenceMacro), here is the assembly for that:<br>






 <br> itkGetConstReferenceMacro(Spacing, SpacingType);<br>000000013F58B720  lea         rax,[rcx+0B8h]  <br>000000013F58B727  ret <br><br></div>RCX = 0000000002111F60<br><br></div>I googled to see if anyone else were having this alignment issue, and it seems not so I wonder if we were doing something to upset the compiler's "natural" alignment. I tried to use /Zp16 [2] compiler option but it appears to only align to the minimum of the "natural" alignment and the Zp parameter, so it does not work. It seems we are forced to use __declspec(align(16)) [3] for all array declaration to fix this issue but that still leaves user and new code unprotected.<br>





<br></div>Does anyone have any suggestions on how to fix this issue?<br><div><br><div>[1] <a href="http://n0ah.org/mirrors/siyobik.info/instruction/DIVPD.html" target="_blank">http://n0ah.org/mirrors/siyobik.info/instruction/DIVPD.html</a><br>





[2] <a href="http://msdn.microsoft.com/en-us/library/xh3e3fd0.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/xh3e3fd0.aspx</a><br>[3] <a href="http://msdn.microsoft.com/en-us/library/83ythb65%28v=vs.80%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/83ythb65%28v=vs.80%29.aspx</a><br>





<br></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">Ho Cheung<br><a href="mailto:hocheung20@gmail.com" target="_blank">hocheung20@gmail.com</a><br>Cell: <a href="tel:%28775%29%20388-2368" value="+17753882368" target="_blank">(775) 388-2368</a></div>




</div>
<br><br><div class="gmail_quote">On Wed, Nov 27, 2013 at 7:23 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div style="word-wrap:break-word">Just to follow up. On the same system I have a clean VS12 (2013) Win32, I have a nightly build for Win64 with 123 test failures. So this confirms that it's just a Win64 issue.<div><br>





</div><div>Brad<div><br><div><br></div><div><br><div><div>On Nov 26, 2013, at 9:46 AM, Simon Alexander <<a href="mailto:skalexander@gmail.com" target="_blank">skalexander@gmail.com</a>> wrote:</div><br>
<blockquote type="cite"><div dir="ltr">I have the same suspicion.  If I can find the time I will look for root cause and a work around if possible.<div><br></div><div>Unfortunately, regressions took precedence and I haven't been able to rerun the dashboard.  I'll look at this again when I have a free machine.</div>







</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 26, 2013 at 8:46 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br>







<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">Hello,<div><br></div><div>Here is my nightly with VS12 32-bit:</div>




<div><br></div><div>


<a href="http://open.cdash.org/buildSummary.php?buildid=3115540" target="_blank">http://open.cdash.org/buildSummary.php?buildid=3115540</a></div><div><br></div><div>It comes back clean.</div><div><br></div><div>There reports have also been that VS12 64-bit in Debug is clean.</div>







<div><br></div><div>Also Simon reports:</div><div><br></div><div><blockquote type="cite"><div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">These seem to maybe be related to copy ctor on itk::Vector types and the optimizer (VS12, 64 bit)</span><br>







</div><div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">e.g.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">







<br></div><div style="font-family:arial,sans-serif;font-size:13px">code that looks like this:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">







<div> typedef typename TOutputImage::SpacingType SpacingType;</div><div> const SpacingType spacing = outputImage->GetSpacing();</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">







leads to a segfault as soon as spacing is accessed (in Release mode, not Debug)</div></div></div></blockquote></div><div><blockquote type="cite"><div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px">but </div>







<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div> typedef typename TOutputImage::SpacingType SpacingType;</div><div> const SpacingType &spacing = outputImage->GetSpacing();</div>







</div></div></blockquote><br></div><div>I am very suspicious that this is not a bug in ITK.</div><div><div><div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px"><br></div></div>

</div><div><div dir="ltr"><div><div style="font-family:arial,sans-serif;font-size:13px"><br></div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">







<br></div></div></div><div><br><div><div>On Nov 25, 2013, at 10:39 PM, Ho Cheung <<a href="mailto:hocheung20@gmail.com" target="_blank">hocheung20@gmail.com</a>> wrote:</div><br><blockquote type="cite">
<div style="word-wrap:break-word">Here’s v4.5rc01 on VS2013 Ultimate 64-bit Release mode. Seems like still quite a lot of segfaults. I’ll have a closer look when I get some time off over Thanksgiving weekend if not solved by then.<div>







<br></div><div><a href="http://open.cdash.org/buildSummary.php?buildid=3114945" target="_blank">http://open.cdash.org/buildSummary.php?buildid=3114945</a> <div><br></div><div>On Nov 25, 2013, at 8:52 AM, Simon Alexander <<a href="mailto:skalexander@gmail.com" target="_blank">skalexander@gmail.com</a>> wrote:<div>







<br><blockquote type="cite"><div dir="ltr">Bradley,<div><br></div><div>Thanks, missed adding the list.  My builds are all 64 bit on 64 bit OS.  I will pull a new copy of master  tonight and manually run the dashboard.</div>







</div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Mon, Nov 25, 2013 at 9:36 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">









<div style="word-wrap:break-word">Simon,<div><br></div><div>I am including the developers list.</div><div><br></div><div>My nightly is 32-bit, perhaps thats related? I'll configure up a 64-bit build nightly too, to see if that's different.</div>









<div><br></div><div>You likely should start with a clean master repo, as start with a fresh CMake configured build too. Results shared on the dashboard are welcomed.</div><div><br></div><div>Brad</div><div>

<div><br></div><div><br></div><div><br><div><div>On Nov 25, 2013, at 9:25 AM, Simon Alexander <<a href="mailto:skalexander@gmail.com" target="_blank">skalexander@gmail.com</a>> wrote:</div><br><blockquote type="cite">









<div dir="ltr">Hi Bradley,<div><br></div><div>It is interesting that the build does not show the same pattern of errors.  If it is helpful I can run the ctest suite again here (win x64, 64 bit builds) but there are certainly things I can't test (like the wrapping).</div>











<div><br></div><div>cheers,</div><div>Simon</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 23, 2013 at 4:07 PM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br>











<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
Thanks for all who have contributed patches and reviews in the last couple of days in preparation of the release candidate.<br>
<br>
I am expecting a good dashboard tomorrow, which should have WrapITK, and VS12 ( 2013 ) green. Here are a couple experimental build I have fired off:<br>
<br>
<a href="http://open.cdash.org/buildSummary.php?buildid=3112037" target="_blank">http://open.cdash.org/buildSummary.php?buildid=3112037</a><br>
<a href="http://open.cdash.org/buildSummary.php?buildid=3112076" target="_blank">http://open.cdash.org/buildSummary.php?buildid=3112076</a><br>
<br>
Interestingly, VS12 has not test failure which is different than had been reported by others.<br>
<br>
Thanks,<br>
Brad<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://kitware.com/products/protraining.php" target="_blank">http://kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/listinfo/insight-developers</a><br>
</blockquote></div><br></div>
</blockquote></div><br></div></div></div></blockquote></div><br></div>
_______________________________________________<br>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>







<br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://kitware.com/products/protraining.php" target="_blank">http://kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br>







<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/listinfo/insight-developers</a><br>







</blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div><div class="gmail_extra">ue, <br></div></div>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div>