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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>