[vtkusers] vtkMath segfault

Pablo Hernandez-Cerdan pablo.hernandez.cerdan at outlook.com
Wed Dec 30 04:26:23 EST 2015


Same here. It seems a double destruction or wrong order of destruction
because vtkMathInternal is static member of vtkMath.
http://stackoverflow.com/questions/6850009/c-deleting-static-data
<http://stackoverflow.com/questions/6850009/c-deleting-static-data>  
suggests a smart pointer for Gaussian, or remove the destructor.

vtk --version = 6.3
//vtkMath.h
static vtkInternal Internal

//vtkMath.cxx
class vtkMathInternal
{
public:
  vtkMathInternal();
  ~vtkMathInternal();
  vtkMinimalStandardRandomSequence *Uniform;
  vtkBoxMuellerRandomSequence *Gaussian;
  std::vector<vtkTypeInt64> MemoizeFactorial;
};

vtkMathInternal::vtkMathInternal()
{
  this->Gaussian=vtkBoxMuellerRandomSequence::New();

  // This line assumes the current vtkBoxMuellerRandomSequence behavior:
  // an initial vtkMinimalStandardRandomSequence is created.
  this->Uniform=static_cast<vtkMinimalStandardRandomSequence *>(
    this->Gaussian->GetUniformSequence());
  this->Uniform->SetSeedOnly(1177); // One authors home address
  this->MemoizeFactorial.resize(21, 0);
}

vtkMathInternal::~vtkMathInternal()
{
  this->Gaussian->Delete();
}

vtkMathInternal vtkMath::Internal;

-----------------------------------

Valgrind output:
valgrind -v --leak-check=full ./google-test-with-fixture.run
...
==32109== Invalid free() / delete / delete[] / realloc()
==32109==    at 0x4C2A144: operator delete(void*) (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==32109==    by 0x1D00781D: vtkMathInternal::~vtkMathInternal()
(vtkMath.cxx:62)

==32109== Invalid read of size 4
==32109==    at 0x1518C4C1: vtkObjectBase::~vtkObjectBase() (in
/usr/lib/libvtkCommonCore.so.1)
==32109==    by 0x1518C588: vtkObjectBase::~vtkObjectBase() (in
/usr/lib/libvtkCommonCore.so.1)
==32109==    by 0x1D00781D: vtkMathInternal::~vtkMathInternal()
(vtkMath.cxx:62)
==32109==    by 0x164D32EE: __cxa_finalize (in /usr/lib/libc-2.22.so)
==32109==    by 0x1CEE42A2: ??? (in
/home/phc/devtoolset/release/VTK/lib/libvtkCommonCore-6.3.so.1)

==32109== Invalid read of size 4
==32109==    at 0x1518C13D:
vtkObjectBase::UnRegisterInternal(vtkObjectBase*, int) (in
/usr/lib/libvtkCommonCore.so.1)
==32109==    by 0x1D00781D: vtkMathInternal::~vtkMathInternal()
(vtkMath.cxx:62)

==32109==    at 0x1518C1F0: vtkObjectBase::Delete() (in
/usr/lib/libvtkCommonCore.so.1)
==32109==    by 0x1D00781D: vtkMathInternal::~vtkMathInternal()
(vtkMath.cxx:62)

==32109== Invalid read of size 8
==32109==    at 0x1518C090: vtkObjectBase::UnRegister(vtkObjectBase*) (in
/usr/lib/libvtkCommonCore.so.1)
==32109==    by 0x1D00781D: vtkMathInternal::~vtkMathInternal()
(vtkMath.cxx:62)







--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkMath-segfault-tp4917184p5735703.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list