MantisBT - VTK
View Issue Details
0012986VTK(No Category)public2012-03-09 10:472014-10-06 11:20
Marc Ferland 
Ben Boeckel (Kitware) 
normalminorhave not tried
closedfixed 
5.8.0 
 
TBD
crash
0012986: Crash in vtkChartXY::RemovePlot
The following call to RemovePlotInstance crashes because of a NULL pointer dereference in vtkChartXY::RemovePlot():996

#include <vtkChartXY.h>
#include <vtkContextScene.h>
#include <vtkContextView.h>
#include <vtkPlotLine.h>

int main()
{
   vtkChartXY *chart = vtkChartXY::New();
   vtkPlot *line = vtkPlotLine::New();
   chart->AddPlot(line);
   chart->RemovePlotInstance(line);
   line->Delete();
   chart->Delete();
   return EXIT_SUCCESS;
}

I'm attaching a patch that fixes it for me (based on tag v5.8.0).
No tags attached.
patch 0001-Check-the-Scene-pointer-before-dereferencing.patch (792) 2012-03-09 10:47
https://www.vtk.org/Bug/file/9130/0001-Check-the-Scene-pointer-before-dereferencing.patch
Issue History
2012-03-09 10:47Marc FerlandNew Issue
2012-03-09 10:47Marc FerlandFile Added: 0001-Check-the-Scene-pointer-before-dereferencing.patch
2012-03-09 10:50Marcus D. HanwellAssigned To => Marcus D. Hanwell
2012-03-09 10:50Marcus D. HanwellStatusbacklog => tabled
2012-03-09 13:30Marcus D. HanwellNote Added: 0028349
2012-03-09 13:56Marc FerlandNote Added: 0028351
2012-03-09 14:22Marc FerlandNote Added: 0028353
2013-07-22 20:02Dave DeMarleStatustabled => backlog
2013-07-22 20:02Dave DeMarleNote Added: 0031253
2014-10-02 11:47Ben Boeckel (Kitware)Assigned ToMarcus D. Hanwell => Ben Boeckel (Kitware)
2014-10-02 12:55Ben Boeckel (Kitware)Note Added: 0033484
2014-10-02 12:55Ben Boeckel (Kitware)Statusbacklog => gerrit review
2014-10-06 11:20Ben Boeckel (Kitware)Note Added: 0033597
2014-10-06 11:20Ben Boeckel (Kitware)Statusgerrit review => closed
2014-10-06 11:20Ben Boeckel (Kitware)Resolutionopen => fixed

Notes
(0028349)
Marcus D. Hanwell   
2012-03-09 13:30   
The patch seems reasonable, but I suspect that there are many other places where we assume Scene is set. What are you trying to do here? There is not much a chart does if it is not in a scene. I can add more null checking to the code.
(0028351)
Marc Ferland   
2012-03-09 13:56   
I'm working on a small pipeline editor and I noticed that if I deleted a vtkContextView _before_ deleting the vtkChartXY a segfault always happened.

The other objects handled by the pipeline editor can be created or deleted in any order, the only exception is this vtkPlot, vtkChartXY relation.
(0028353)
Marc Ferland   
2012-03-09 14:22   
Another case is when I clear my pipeline editor (by deleting all objects making the pipeline), since objects are deleted in no particular order a crash sometimes happen.
(0031253)
Dave DeMarle   
2013-07-22 20:02   
moving all "tabled" bugs into "backlog" category since "tabled" is no longer used.
(0033484)
Ben Boeckel (Kitware)   
2014-10-02 12:55   
Fixed on Gerrit http://review.source.kitware.com/#/t/4766 [^] (as well as a few others when I played around with ChartXYZ as well).
(0033597)
Ben Boeckel (Kitware)   
2014-10-06 11:20   
The branch has been merged.