MantisBT - VTK
View Issue Details
0000693VTK(No Category)public2004-03-22 11:232013-04-05 19:57
Marcel Jackowski 
Zhanping Liu 
urgentmajoralways
closedopen 
 
 
0000693: vtkHyperStreamline
This class seg faults if pointer sPtr is accessed after a call to InsertNextHyperPoint if the array of points gets resized. Below follows the snippet where crashing typically occur.

excerpt from line 531:

sNext = this->Streamers[ptId].InsertNextHyperPoint();

      if ( cell->EvaluatePosition(xNext, closestPoint, sNext->SubId,
      sNext->P, dist2, w) )
        { //integration still in cell
        for (i=0; i<3; i++)
          {
          sNext->X[i] = closestPoint[i];
          }
        sNext->CellId = sPtr->CellId; (crashes if array is resized - sPtr is not valid anymore)
        sNext->SubId = sPtr->SubId;
        }
      else ...

A temporary fix can be done by restoring the sPtr pointer after insertion of new point:

 // get a hold of the number of points
      index = this->Streamers[ptId].GetNumberOfPoints();
      
      // insert next point
      sNext = this->Streamers[ptId].InsertNextHyperPoint();
      
      // make sure sPtr is still valid after possible Resizing
      sPtr = this->Streamers[ptId].GetHyperPoint(index-1);
No tags attached.
Issue History
2008-09-23 11:28Berk GeveciAssigned ToMathieu Malaterre => Zhanping Liu
2008-10-02 11:43Zhanping LiuNote Added: 0013707
2008-10-02 11:43Zhanping LiuNote Added: 0013708
2008-10-02 11:45Zhanping LiuStatustabled => @80@
2008-10-02 11:45Zhanping LiuDescription Updated
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2013-04-05 19:57Berk GeveciStatuscustomer review => closed

Notes
(0000788)
Mathieu Malaterre   
2004-03-22 17:52   
Mjack,

   could you please provide more info about the 'resize' problem. I don't have any example in mind where the data is resized. The ideal case would be that you provide a python/c++/tcl example that shows the crash.
Thanks
(0013707)
Zhanping Liu   
2008-10-02 11:43   
BUG: 0000693 has been fixed. The problem was due to a broken / wild pointer (sPtr) indirectly caused through (new line #559 or old line 0000531)

     =============================================
     this->Streamers[ptId].InsertNextHyperPoint();
     =============================================

     in vtkHyperStreamline::RequestData().

Now a safe handle to, i.e., the index of, sPtr in the vtkHyperPoint Array (Streamers[ptId]) is saved immediately before

     =============================================
     this->Streamers[ptId].InsertNextHyperPoint();
     =============================================

     and sPtr is guaranteed to point to the target after a possible memory resize operation.

     Thanks for reporting this bug and the great suggestions.
(0013708)
Zhanping Liu   
2008-10-02 11:43   
new revision: 1.62; previous revision: 1.61