[vtkusers] vtkGraph::AddVertex segfault
Caleb Johnston
cjj37 at cornell.edu
Thu May 13 15:17:23 EDT 2010
The code is not that compilable without Qt, VTK, ITK, and Cmake installed.
It is publicly hosted at SourceForge:
http://sourceforge.net/projects/glassbrain/
And the stack trace shows the problem arrises from the AddVertex call.
On Thu, May 13, 2010 at 2:25 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:
> On Thu, May 13, 2010 at 2:16 PM, Caleb Johnston <cjj37 at cornell.edu> wrote:
> > I'm getting a segfault when calling vtkMutableUndirectedGraph::AddVertex.
> > However, it does not always occur at the same vertex. Sometimes it is
> after
> > the 2nd vertex. Sometimes it won't happen at all (though rarely). I'm
> only
> > adding about 120 vertices. And the program is not consuming large amounts
> of
> > data so I don't understand why this is happening. Also, this only happens
> in
> > Linux and Windows but not MacOS X. Below, I have included my algorithm
> for
> > adding vertices.
> > thanks,
> > Caleb
> > ...
> > int len = 0;
> > double X,Y,Z,Count;
> > for(i=0, j=0; j<numberOfLabels; i+=3, j++){
> > X = (double)coords[i];
> > Y = (double)coords[i+1];
> > Z = (double)coords[i+2];
> > Count = (double)centroids[j];
> > if(Count>0.0){
> > X = X / Count;
> > Y = Y / Count;
> > Z = Z / Count;
> > len++;
> > graph->AddVertex(); // crashes here.
> > graph->Update();
> > points->InsertNextPoint(X, Y, Z);
> > }
> > }
> > ...
>
> I've used this in Linux plenty of times with no problems. If you post
> some compilable code I can see if it works on my machine. My initial
> bet is that something is going wrong around there, like accessing out
> of bounds elements in coords or centroids.
>
> Thanks,
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100513/4f59d8f4/attachment.htm>
More information about the vtkusers
mailing list