segmentation fault when saving png of Constant

Issue #554 resolved
Chaffra Affouda created an issue

I am getting a seg fault when doing

mesh = UnitCubeMesh(10,10,10)
plotter = plot(Constant(1.0),mesh=mesh)
plotter.write_png('test.png') # breaks here

but if I do

mesh = UnitCubeMesh(10,10,10)
Q = FunctionSpace(mesh,'CG',1)
f = Function(Q)
f.vector()[:] = 1.0
plotter = plot(f)
plotter.write_png('test.png') # works here

I could track down the problem to "_function.lock()->compute_vertex_values(vertex_values, *mesh);" in VTKPlottableGenericFunction.cpp. Apperently _function is a std::weak_ptr and that seems to be the problem. Can anyone reproduce?

Comments (7)

  1. Mattia Tamellini

    Hi,

    I also found the snippet posted above to give a segmentation fault. Actually, I get a segmentation fault with both the versions posted (or better, with the C++ equivalent of both the versions). Has this been fixed in the latest commits?

  2. Martin Sandve Alnæs

    I get this:

    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    <ipython-input-5-b76fd35ce204> in <module>()
    ----> 1 plotter.write_png('test.png') # breaks here
    
    RuntimeError: 
    
    *** -------------------------------------------------------------------------
    *** DOLFIN encountered an error. If you are not able to resolve this issue
    *** using the information listed below, you can ask for help at
    ***
    ***     fenics-support@googlegroups.com
    ***
    *** Remember to include the error message listed below and, if possible,
    *** include a *minimal* running example to reproduce the error.
    ***
    *** -------------------------------------------------------------------------
    *** Error:   Unable to complete call to function update().
    *** Reason:  Assertion !_function.expired() failed.
    *** Where:   This error was encountered inside ../../dolfin/plot/VTKPlottableGenericFunction.cpp (line 232).
    *** Process: 0
    *** 
    *** DOLFIN version: 1.7.0dev
    *** Git changeset:  da023d201c0e75fafdb72617bfb0b0effa9b3537
    *** -------------------------------------------------------------------------
    
  3. Prof Garth Wells

    Looks like the version of plot that takes a references (to meshes and expressions) needs to be ignored in the SWIG layer.

    Simpler fix would be to just remove it and force use of the shared_ptr version.

  4. Log in to comment