VTK crashed while setting LD_PRELOAD with libGLEW.so

Hi there,

My System environment is Ubuntu 16.04, and I installed vtk via pip install vtk

If I set

export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libGLEW.so

then every time when I use vtk in python the program will crash, and prompted Segmentation fault (core dumped).

For example, the following python scripts will reproduce the crash.

#!/usr/bin/env python
#
import vtk
import time

cone = vtk.vtkConeSource()
cone.SetHeight(3.0)
cone.SetRadius(1.0)
cone.SetResolution(10)

coneMapper = vtk.vtkPolyDataMapper()
coneMapper.SetInputConnection(cone.GetOutputPort())

coneActor = vtk.vtkActor()
coneActor.SetMapper(coneMapper)

ren = vtk.vtkRenderer()
ren.AddActor(coneActor)
ren.SetBackground(0.1, 0.2, 0.4)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(500, 500)

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

for i in range(0, 180):
    time.sleep(0.01)
    renWin.Render()
    ren.GetActiveCamera().Azimuth(1)

iren.Start()

However if I do NOT set the variable LD_PRELOAD with libGLEW.so, everything works well.

I was wondering how to resolve this issue, coz I do not want to manually cancel the LD_PRELOAD variable every time before using vtk.

Thanks in advance.

Why do you have LD_PRELOAD in your environment in the first place? All guarantees of anything working with that are off the table when LD_PRELOAD is involved. There’s nothing (practical) VTK can do to fix this at all. You really should only set it when necessary, not everywhere and attempt to remove it when it isn’t needed.