python segfault on mayavi masking

When enabling “Mask input points” python crashes/segfaults because it tries to allocate 9223372036854775805 elements of 4 bytes (thats 3,7e19 bytes!).

Error message is:

ERROR: In /tmp/-ShMM/VTK5.10.1/Common/vtkDataArrayTemplate.txx, line 144
vtkFloatArray (0x7ff37757da60): Unable to allocate 9223372036854775805 elements of size 4 bytes. 

Seems this is because “Max number of points” is set to 9223372036854775805 by default, and I’ts not possible to change from the mayavi pipeline window (greyed out). Yey!

Anyhow, to fix this, set “Max number of points” before turning masking on. Do it this way:

# Plot
fig = figure(1, size=(400, 400), bgcolor=(1, 1, 1), fgcolor=(0, 0, 0)) # figure with white background

# prevent segfautl (malloc too large) on osx
vectors = fig.children[0].children[0].children[0]
vectors.glyph.mask_points.maximum_number_of_points = 1000 # "Manually" set Maximum number of points
vectors.glyph.mask_input_points = True # turn masking on

Mayavi on OS X Mountain Lion 10.8.5

1. Get homebrew:
2. Install homebrew’s version of python:

brew install python

(You should probably get SciPy too:
3. Change path so that /usr/local/bin is listed first: /etc/paths


4. Close console and open again to get new path.
5. Install pyqt:

brew install pyqt

6. Install version 5.10.1 of vtk (6.0.0 is currently not working):

brew tap  homebrew/science
brew versions vtk #list versions of vtk
cd /usr/local/Library/Taps/homebrew-science/ #so that git finds vtk repository
git checkout 27a4327 /usr/local/Library/Taps/homebrew-science/vtk.rb #checkout version 5.10.1
homebrew install vtk

7. Install mayavi:

pip install mayavi

8. Install ipython:

easy_install ipython

9. Run your mayavi plot: