segmentation fault when saving png of Constant
Issue #554
resolved
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)
-
-
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 *** -------------------------------------------------------------------------
-
So I take it the answer to my question is "no" :)
-
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. -
- removed responsible
- changed milestone to 1.7
-
- changed status to resolved
Fix Issue
#554.Should really remove the plot functions that take references.
→ <<cset 43fc46a0d5df>>
-
- removed milestone
Removing milestone: 1.7 (automated comment)
- Log in to comment
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?