[Insight-users] Segmentation Fault in Node iterator

Luis Ibanez luis.ibanez at kitware.com
Fri Mar 23 16:38:53 EST 2007


Hi Sonali,

I would guess that there is a problem with the code
that generates your It_Node collection.

You should review that code.

It is unlikely that you will find the solution to
your problem in the for-loop where the segmentation
fault happens.



     Regards,



         Luis



------------------------
Sonali Barua wrote:
> I get it at GetPointer().
> 
> I tried not using Iterators and using a simple for loop and it works 
> until the 30th iteration till it gives me a std3_bad::alloc error. I am 
> not sure how to handle this.
> 
> Sonali.
> 
> On 3/22/07, *Luis Ibanez* <luis.ibanez at kitware.com 
> <mailto:luis.ibanez at kitware.com>> wrote:
> 
> 
>     In what line *exactly* do you get the segmentation fault ?
> 
> 
>     --------------------------
>     Sonali Barua wrote:
>      > I did add the GetPointer()==NULL code and it still gives me a seg
>     fault.
>      >
>      > On 3/22/07, *Luis Ibanez* < luis.ibanez at kitware.com
>     <mailto:luis.ibanez at kitware.com>
>      > <mailto:luis.ibanez at kitware.com
>     <mailto:luis.ibanez at kitware.com>>> wrote:
>      >
>      >
>      >     Hi Sonali,
>      >
>      >     You should check whether
>      >
>      >          It_Node.GetPointer()
>      >
>      >     is NULL or not, before attemting
>      >     to access its member variables.
>      >
>      >     It is likely that this pointer is NULL,
>      >     which probably indicates that there is
>      >     a problem with the code that generates
>      >     the It_Node structure.
>      >
>      >     Please add a check for GetPointer()==NULL
>      >     and let us know what you find.
>      >
>      >
>      >        Thanks
>      >
>      >
>      >           Luis
>      >
>      >
>      >     ============================
>      >     Sonali Barua wrote:
>      >      > Hello,
>      >      >
>      >      > I am trying to run a code I am trying to develop for ITK
>     in a loop:
>      >      >
>      >      > for(It_Node.GoToBegin();!It_Node.IsAtEnd();++It_Node)
>      >      >    {
>      >      >      IdentifierType id=It_Node.GetPointer()->Identifier;
>      >      >
>      >      >      prim->SetRootNodeIdentifier(id);  //this is a
>     itkSetMacro
>      >      >      graph->Modified();
>      >      >      prim->Modified();
>      >      >      prim->Update();
>      >      >       std::cout<<" The distance of the minimumspanning
>     tree is for
>      >      > Rootnode Id: "<<id<<" is
>     "<<prim->GetDistanceWeight()<<std::endl;
>      >      >     }
>      >      > I get a Seg Fault around the third Iteration at the
>      >      > It_Node.GetPointer->Identifier part of the code.
>      >      >
>      >      > I change the Graph that is set as an Input in the Prim
>     object. Could
>      >      > that be a problem?
>      >      >
>      >      >
>      >
>      >
> 
> 


More information about the Insight-users mailing list