View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015909VTK(No Category)public2015-12-30 04:312016-08-12 09:55
ReporterPablo Hernandez-Cerdan 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version6.3.0 
Target VersionFixed in Version 
Summary0015909: segfault in destruction of static member vtkMathInternal in vtkMath
DescriptionI reported first into the mail-list, but I thought was more suitable for a ticket: http://vtk.1045678.n5.nabble.com/vtkMath-segfault-td4917184.html#a5735703 [^]

It seems a double destruction or wrong order of destruction of member pointer Gaussian of vtkMathInternal, which is static member of vtkMath
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)
TagsNo tags attached.
ProjectRelease
Typecrash
Attached Files? file icon valgrind.out [^] (94,886 bytes) 2015-12-30 04:31

 Relationships

  Notes
(0036172)
Shawn Waldon (developer)
2016-07-06 10:55

Can you provide a simple script that can be run in valgrind to reproduce this error? My test of a common usage of vtkMath doesn't reproduce this. Since Internal is a static variable, it should be deleted at program exit which only happens once. What are you doing that is causing a double free?
(0036318)
Pablo Hernandez-Cerdan (reporter)
2016-07-06 22:55
edited on: 2016-07-06 22:56

I am not able to reproduce it neither! I checked git history, checkout the closest -by date- script that I used valgrind in this bug report, but no errors. I changed the computer, if that can save me from the fire.

The valgrind output submitted here shows that no google test was running, but the memory leak exists anyway?. Maybe it was related with some google fixture... sorry, I will attach a simple script next time :(

(0037442)
Kitware Robot (administrator)
2016-08-12 09:55

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2015-12-30 04:31 Pablo Hernandez-Cerdan New Issue
2015-12-30 04:31 Pablo Hernandez-Cerdan File Added: valgrind.out
2016-07-06 10:26 Shawn Waldon Assigned To => Shawn Waldon
2016-07-06 10:55 Shawn Waldon Note Added: 0036172
2016-07-06 10:56 Shawn Waldon Assigned To Shawn Waldon =>
2016-07-06 22:55 Pablo Hernandez-Cerdan Note Added: 0036318
2016-07-06 22:56 Pablo Hernandez-Cerdan Note Edited: 0036318
2016-08-12 09:55 Kitware Robot Note Added: 0037442
2016-08-12 09:55 Kitware Robot Status backlog => closed
2016-08-12 09:55 Kitware Robot Resolution open => moved
2016-08-12 09:55 Kitware Robot Assigned To => Kitware Robot


Copyright © 2000 - 2018 MantisBT Team