<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">It is a compiler issue.<br>
      I compiled in release mode ITK and the test code using gcc 4.3 and
      it works fine.<br>
      The problem seems raises with gcc 4.8 and 4.7<br>
      <br>
      Thanks a lot.<br>
      Paolo<br>
      <br>
      <br>
      <br>
      On 28/06/2013 13:14, Bill Lorensen wrote:<br>
    </div>
    <blockquote
cite="mid:CADZJ4hP8p0Wt3Z3TnKuwE=4cEYhcs6bi+_FqybBrNxiz25MZJw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>I tried your code on both itkv3 and itkv4. With my own
          data, they both ran.<br>
          <br>
        </div>
        What data format are you using?<br>
        <br>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Fri, Jun 28, 2013 at 11:38 AM, Paolo
          Zaffino <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:p.zaffino@yahoo.it" target="_blank">p.zaffino@yahoo.it</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>Hi,<br>
                this is the output:<br>
                <br>
                Image (0x2a2cdf0)<br>
                &nbsp; RTTI typeinfo:&nbsp;&nbsp; itk::Image&lt;unsigned char, 3u&gt;<br>
                &nbsp; Reference Count: 1<br>
                &nbsp; Modified Time: 193<br>
                &nbsp; Debug: Off<br>
                &nbsp; Observers: <br>
                &nbsp;&nbsp;&nbsp; none<br>
                &nbsp; Source: (0x2a28a10) <br>
                &nbsp; Source output index: 0<br>
                &nbsp; Release Data: Off<br>
                &nbsp; Data Released: False<br>
                &nbsp; Global Release Data: Off<br>
                &nbsp; PipelineMTime: 10<br>
                &nbsp; UpdateMTime: 194<br>
                &nbsp; LargestPossibleRegion: <br>
                &nbsp;&nbsp;&nbsp; Dimension: 3<br>
                &nbsp;&nbsp;&nbsp; Index: [0, 0, 0]<br>
                &nbsp;&nbsp;&nbsp; Size: [512, 512, 89]<br>
                &nbsp; BufferedRegion: <br>
                &nbsp;&nbsp;&nbsp; Dimension: 3<br>
                &nbsp;&nbsp;&nbsp; Index: [0, 0, 0]<br>
                &nbsp;&nbsp;&nbsp; Size: [512, 512, 89]<br>
                &nbsp; RequestedRegion: <br>
                &nbsp;&nbsp;&nbsp; Dimension: 3<br>
                &nbsp;&nbsp;&nbsp; Index: [0, 0, 0]<br>
                &nbsp;&nbsp;&nbsp; Size: [512, 512, 89]<br>
                &nbsp; Spacing: [0.539, 0.539, 2.5]<br>
                &nbsp; Origin: [0, 0, 0]<br>
                &nbsp; Direction: <br>
                1 0 0<br>
                0 1 0<br>
                0 0 1<br>
                <br>
                &nbsp; IndexToPointMatrix: <br>
                &nbsp; 0.539 0 0<br>
                0 0.539 0<br>
                0 0 2.5<br>
                <br>
                &nbsp; PointToIndexMatrix: <br>
                &nbsp; 1.85529 0 0<br>
                0 1.85529 0<br>
                0 0 0.4<br>
                <br>
                &nbsp; PixelContainer: <br>
                &nbsp;&nbsp;&nbsp; ImportImageContainer (0x2a2d050)<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTTI typeinfo:&nbsp;&nbsp;
                itk::ImportImageContainer&lt;unsigned long, unsigned
                char&gt;<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Reference Count: 1<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Modified Time: 192<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug: Off<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Observers: <br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; none<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pointer: 0x7f5cf3736010<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Container manages memory: true<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size: 23330816<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Capacity: 23330816<br>
                <br>
                <br>
                Thanks.<span class="HOEnZb"><font color="#888888"><br>
                    Paolo</font></span>
                <div>
                  <div class="h5"><br>
                    <br>
                    <br>
                    <br>
                    On 28/06/2013 11:02, Bill Lorensen wrote:<br>
                  </div>
                </div>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div>
                        <div>After reader-&gt;Update()<br>
                          <br>
                        </div>
                        put<br>
                        reader-&gt;GetOutput()-&gt;Print(std::cout);<br>
                      </div>
                      to see the read image.<br>
                    </div>
                    <div class="gmail_extra"><br>
                      <br>
                      <div class="gmail_quote">On Thu, Jun 27, 2013 at
                        9:16 PM, Paolo Zaffino <span dir="ltr">&lt;<a
                            moz-do-not-send="true"
                            href="mailto:p.zaffino@yahoo.it"
                            target="_blank">p.zaffino@yahoo.it</a>&gt;</span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <table border="0" cellpadding="0"
                            cellspacing="0">
                            <tbody>
                              <tr>
                                <td valign="top">
                                  <p dir="ltr">Hi,<br>
                                    The strange thing is that in debug
                                    mode (both ITK that my code) it
                                    works fine.</p>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                          <div>
                            <div> <br>
                              <div> </div>
                              <div>
                                <div>
                                  <div style="font-size:0.9em">
                                    <hr size="1"> <b> <span
                                        style="font-weight:bold">From:</span>
                                    </b> Bradley Lowekamp &lt;<a
                                      moz-do-not-send="true"
                                      href="mailto:blowekamp@mail.nih.gov"
                                      target="_blank">blowekamp@mail.nih.gov</a>&gt;;

                                    <br>
                                    <b> <span style="font-weight:bold">To:</span>
                                    </b> Paolo Zaffino &lt;<a
                                      moz-do-not-send="true"
                                      href="mailto:p.zaffino@yahoo.it"
                                      target="_blank">p.zaffino@yahoo.it</a>&gt;;

                                    <br>
                                    <b> <span style="font-weight:bold">Cc:</span>
                                    </b> Bill Lorensen &lt;<a
                                      moz-do-not-send="true"
                                      href="mailto:bill.lorensen@gmail.com"
                                      target="_blank">bill.lorensen@gmail.com</a>&gt;;

                                    <a moz-do-not-send="true"
                                      href="mailto:insight-users@itk.org"
                                      target="_blank">insight-users@itk.org</a>
                                    &lt;<a moz-do-not-send="true"
                                      href="mailto:insight-users@itk.org"
                                      target="_blank">insight-users@itk.org</a>&gt;;
                                    <br>
                                    <b> <span style="font-weight:bold">Subject:</span>
                                    </b> Re: [Insight-users]
                                    itkImageMaskSpatialObject
                                    segmentation fault <br>
                                    <b> <span style="font-weight:bold">Sent:</span>
                                    </b> Thu, Jun 27, 2013 11:17:06 PM <br>
                                  </div>
                                </div>
                                <div>
                                  <div> <br>
                                    <table border="0" cellpadding="0"
                                      cellspacing="0">
                                      <tbody>
                                        <tr>
                                          <td valign="top">Hello,
                                            <div><br>
                                            </div>
                                            <div>I don't see anything
                                              obviously wrong with your
                                              code, but I haven't
                                              recently used that class
                                              myself.</div>
                                            <div><br>
                                            </div>
                                            <div>Do you know how to run
                                              the program in &nbsp;gdb to
                                              determine where the
                                              segfault is happening? A
                                              stack trace is quite
                                              useful for tracking down
                                              this type of error.</div>
                                            <div><br>
                                            </div>
                                            <div>Brad</div>
                                            <div><br>
                                            </div>
                                            <div>
                                              <div>
                                                <div>On Jun 27, 2013, at
                                                  1:43 PM, Paolo Zaffino
                                                  &lt;<a
                                                    moz-do-not-send="true"
                                                    rel="nofollow">p.zaffino@yahoo.it</a>&gt;

                                                  wrote:</div>
                                                <br>
                                                <blockquote type="cite">
                                                  <div>
                                                    <div>The problem is
                                                      not in the
                                                      reader-&gt;Update()
                                                      but in<br>
mask-&gt;SetImage(reader-&gt;GetOutput());<br>
                                                      <br>
                                                      Until this row it
                                                      is ok.<br>
                                                      <br>
                                                      <br>
                                                      <br>
                                                      <br>
                                                      On 27/06/2013
                                                      16:37, Bill
                                                      Lorensen wrote:<br>
                                                    </div>
                                                    <blockquote
                                                      type="cite">
                                                      <div dir="ltr">You
                                                        should put a
                                                        try/catch around
                                                        reader-&gt;Update().
                                                        It may provide
                                                        for information.<br>
                                                        <br>
                                                        <a
                                                          moz-do-not-send="true"
                                                          rel="nofollow"
href="http://itk.org/Wiki/ITK/Examples/SimpleOperations/TryCatch"
                                                          target="_blank">http://itk.org/Wiki/ITK/Examples/SimpleOperations/TryCatch</a><br>
                                                        <br>
                                                      </div>
                                                      <div
                                                        class="gmail_extra"><br>
                                                        <br>
                                                        <div
                                                          class="gmail_quote">On

                                                          Thu, Jun 27,
                                                          2013 at 4:25
                                                          PM, Paolo
                                                          Zaffino <span
                                                          dir="ltr">&lt;<a
moz-do-not-send="true" rel="nofollow">p.zaffino@yahoo.it</a>&gt;</span>
                                                          wrote:<br>
                                                          <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0
                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">Dear

                                                          ITK community,<br>
                                                          I'm facing a
                                                          strange ITK
                                                          behavior.<br>
                                                          I wrote this
                                                          code:<br>
                                                          <br>
                                                          #include
                                                          "itkImage.h"<br>
                                                          #include
                                                          "itkImageFileReader.h"<br>
                                                          #include
                                                          "itkImageMaskSpatialObject.h"<br>
                                                          <br>
                                                          int main( int
                                                          argc, char
                                                          **argv )<br>
                                                          {<br>
                                                          &nbsp; typedef
                                                          itk::Image&lt;unsigned
                                                          char,3&gt;
                                                          ImageType;<br>
                                                          &nbsp; typedef
                                                          itk::ImageFileReader&lt;ImageType&gt;
                                                          ReaderType;<br>
                                                          <br>
                                                          &nbsp; typedef
                                                          itk::ImageMaskSpatialObject&lt;3&gt;
                                                          MaskImageType;<br>
                                                          &nbsp; typedef
                                                          MaskImageType::Pointer
MaskTypePointer;<br>
                                                          <br>
                                                          &nbsp;
                                                          ReaderType::Pointer
                                                          reader =
                                                          ReaderType::New();<br>
                                                          <br>
                                                          &nbsp;
                                                          reader-&gt;SetFileName(
                                                          argv[1] );<br>
                                                          &nbsp;
                                                          reader-&gt;Update();<br>
                                                          <br>
                                                          &nbsp;
                                                          MaskTypePointer
                                                          mask =
                                                          MaskImageType::New();<br>
                                                          &nbsp;
                                                          mask-&gt;SetImage(reader-&gt;GetOutput());<br>
                                                          <br>
                                                          &nbsp; return 0;<br>
                                                          }<br>
                                                          <br>
                                                          and it
                                                          compiles
                                                          without error.<br>
                                                          When I try to
                                                          run the
                                                          executable I
                                                          get a
                                                          segmentation
                                                          error (core
                                                          dumped).<br>
                                                          What's is
                                                          wrong?<br>
                                                          I'm using ITK
                                                          3.20.1 on a 64
                                                          bit Linux box.<br>
                                                          If needed I
                                                          can provide
                                                          the mask
                                                          image.<br>
                                                          <br>
                                                          Thanks a lot
                                                          for your help.<br>
                                                          Best regards.<br>
                                                          Paolo<br>
_____________________________________<br>
                                                          Powered by <a
moz-do-not-send="true" rel="nofollow" href="http://www.kitware.com/"
                                                          target="_blank">www.kitware.com</a><br>
                                                          <br>
                                                          Visit other
                                                          Kitware
                                                          open-source
                                                          projects at<br>
                                                          <a
                                                          moz-do-not-send="true"
                                                          rel="nofollow"
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
                                                          moz-do-not-send="true"
                                                          rel="nofollow"
href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
                                                          <br>
                                                          Please keep
                                                          messages
                                                          on-topic and
                                                          check the ITK
                                                          FAQ at:<br>
                                                          <a
                                                          moz-do-not-send="true"
                                                          rel="nofollow"
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
                                                          moz-do-not-send="true"
                                                          rel="nofollow"
href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
                                                          </blockquote>
                                                        </div>
                                                        <br>
                                                        <br clear="all">
                                                        <br>
                                                        -- <br>
                                                        Unpaid intern in
                                                        BillsBasement at
                                                        noware dot com<br>
                                                      </div>
                                                    </blockquote>
                                                    <br>
                                                  </div>
_____________________________________<br>
                                                  Powered by <a
                                                    moz-do-not-send="true"
                                                    rel="nofollow"
                                                    href="http://www.kitware.com"
                                                    target="_blank">www.kitware.com</a><br>
                                                  <br>
                                                  Visit other Kitware
                                                  open-source projects
                                                  at<br>
                                                  <a
                                                    moz-do-not-send="true"
                                                    rel="nofollow"
                                                    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
                                                    moz-do-not-send="true"
href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
                                                  <br>
                                                  Please keep messages
                                                  on-topic and check the
                                                  ITK FAQ at:<br>
                                                  <a
                                                    moz-do-not-send="true"
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
                                                    moz-do-not-send="true"
href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
                                                </blockquote>
                                              </div>
                                              <br>
                                            </div>
                                          </td>
                                        </tr>
                                      </tbody>
                                    </table>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                      <br>
                      <br clear="all">
                      <br>
                      -- <br>
                      Unpaid intern in BillsBasement at noware dot com<br>
                    </div>
                  </blockquote>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        Unpaid intern in BillsBasement at noware dot com<br>
      </div>
    </blockquote>
    <br>
  </body>
</html>