enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

GeometryFilter IOT instruction (core dumped) #1107

Closed JaRoSchm closed 2 years ago

JaRoSchm commented 2 years ago

Hi, while my first issue with clipping using the GeometryFilter (#1071) was fixed, I now noticed a new error with the newest Mayavi 4.7.4 and VTK 9.1.0. The example below fails in about 50 % of the cases with

double free or corruption (fasttop)
[1]    328047 IOT instruction (core dumped)  python test.py

The example (same as in #1071) reproducing this error is adopted from https://docs.enthought.com/mayavi/mayavi/auto/example_adjust_cropping_extents.html

import numpy as np
from mayavi import mlab

x, y, z, s = np.random.random((4, 500))

# Now build the visualization using mlab
fig = mlab.figure(1, bgcolor=(1, 1, 1))

# Create unconnected points
pts = mlab.pipeline.scalar_scatter(x, y, z, s)
mlab.outline(pts)

# Use a geometry_filter to filter with a bounding box
geometry_filter = mlab.pipeline.user_defined(pts, filter="GeometryFilter")
geometry_filter.filter.extent_clipping = True
# Connect our dialog to the filter
geometry_filter.filter.extent = [0.0, 1.0, 0.0, 1.0, 0.0, 0.8]

# The geometry_filter leaves hanging points, we need to add a
# CleanPolyData filter to get rid of these.
clip = mlab.pipeline.user_defined(geometry_filter, filter="CleanPolyData")

# Finally, visualize the remaining points with spheres using a glyph
# module
spheres = mlab.pipeline.glyph(clip, scale_factor=0.1)

mlab.show()
prabhuramachandran commented 2 years ago

@JaRoSchm -- I am not able to reproduce this on MacOS. What platform are you trying this on? I also added a test case for this that should catch the error on all platforms but then you seem to be getting this intermittently. Are you sure you don't have a lingering older version of Mayavi? Can you try to pip uninstall mayavi and then re-install it and try then?

JaRoSchm commented 2 years ago

This happened on two PCs with Ubuntu 21.10 and 20.04. Mayavi and VTK are installed in a conda environment with Python 3.9.7. I tried it again with a new environment with the installed packages listed below.

- name: test - channels: - - defaults - dependencies: - - _libgcc_mutex=0.1=main - - _openmp_mutex=4.5=1_gnu - - ca-certificates=2021.10.26=h06a4308_2 - - certifi=2021.10.8=py39h06a4308_0 - - ld_impl_linux-64=2.35.1=h7274673_9 - - libffi=3.3=he6710b0_2 - - libgcc-ng=9.3.0=h5101ec6_17 - - libgomp=9.3.0=h5101ec6_17 - - libstdcxx-ng=9.3.0=hd4cf53a_17 - - ncurses=6.3=h7f8727e_2 - - openssl=1.1.1l=h7f8727e_0 - - pip=21.2.4=py39h06a4308_0 - - python=3.9.7=h12debd9_1 - - readline=8.1=h27cfd23_0 - - setuptools=58.0.4=py39h06a4308_0 - - sqlite=3.36.0=hc218d9a_0 - - tk=8.6.11=h1ccaba5_0 - - tzdata=2021e=hda174b7_0 - - wheel=0.37.0=pyhd3eb1b0_1 - - xz=5.2.5=h7b6447c_0 - - zlib=1.2.11=h7b6447c_3 - - pip: - - aiohttp==3.8.1 - - aiosignal==1.2.0 - - apptools==5.1.0 - - async-timeout==4.0.1 - - attrs==21.2.0 - - charset-normalizer==2.0.7 - - configobj==5.0.6 - - cycler==0.11.0 - - envisage==6.0.1 - - fonttools==4.28.1 - - frozenlist==1.2.0 - - idna==3.3 - - importlib-metadata==4.8.2 - - importlib-resources==5.4.0 - - kiwisolver==1.3.2 - - matplotlib==3.5.0 - - mayavi==4.7.4 - - multidict==5.2.0 - - numpy==1.21.4 - - packaging==21.2 - - pillow==8.4.0 - - pyface==7.3.0 - - pygments==2.10.0 - - pyparsing==2.4.7 - - pyqt5==5.15.6 - - pyqt5-qt5==5.15.2 - - pyqt5-sip==12.9.0 - - python-dateutil==2.8.2 - - setuptools-scm==6.3.2 - - six==1.16.0 - - tomli==1.2.2 - - traits==6.3.2 - - traitsui==7.2.1 - - typing-extensions==4.0.0 - - vtk==9.1.0 - - wslink==1.1.0 - - yarl==1.7.2 - - zipp==3.6.0
prabhuramachandran commented 2 years ago

Could you run this under gdb and show a traceback?

JaRoSchm commented 2 years ago

This is quite interesting. If I run the program under gdb it works all the time. Without gdb the problem is still present. This sounds like described in this StackOverflow question: https://stackoverflow.com/questions/30043750/no-segmentation-fault-if-program-running-under-gdb. So this could be a VTK error?

JaRoSchm commented 2 years ago

Using VTK 9.0.3 fixed this problem for now. This is at least a temporary solution for me. Unfortunately, I don't have any knowledge about C or the pure VTK Python library to report this issue at the VTK repo. From reading some things I suspect that a race condition is the origin of this issue.

JaRoSchm commented 2 years ago

This seems to be fixed by uninstalling libtcmalloc-minimal4 although I have no idea how this could be related.