vtkOpenSlideReader fails to initialize openslide_handle
I received a bug report (https://bugzilla.redhat.com/show_bug.cgi?id=1966135) about an import of mayavi modules failing:
python3 -c 'from mayavi.mlab import *'
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007fffc4eda58e in openslide_close (osr=0xdc467) at src/openslide.c:351
351 if (osr->ops) {
(gdb) print *osr
Cannot access memory at address 0xdc467
I believe the issue is that vtkOpenSlideReader is not initializing openslide_handle on object creation, and then in this case the object is being destroyed without it being later initialized. Valgrind reports:
==15258== Conditional jump or move depends on uninitialised value(s)
==15258== at 0x3893B760: vtkOpenSlideReader::~vtkOpenSlideReader() (in /usr/lib64/libvtkDomainsMicroscopy.so.9.0.1)
==15258== by 0x3893B77C: vtkOpenSlideReader::~vtkOpenSlideReader() (in /usr/lib64/libvtkDomainsMicroscopy.so.9.0.1)
which appears to be this:
145 vtkOpenSlideReader::~vtkOpenSlideReader()
146 {
147 // Release openslide_handle if being used
148 if (this->openslide_handle != nullptr)
149 {
(gdb) print this->openslide_handle
$3 = (openslide_t *) 0xdc467
since it is not null it does on to call openslide_close() with an invalid handle.