Mesh function memory corruption

Issue #467 resolved
Jan Blechta created an issue

This example

from dolfin import *

def ff():
    mesh = UnitSquareMesh(3, 3)
    ff = FacetFunction('size_t', mesh)
    #ff._mesh = mesh # Workaround
    return ff

ff = ff()
print ff.mesh().geometry().dim() # prints rubish
print ff.mesh().coordinates() # prints rubish

demonstrates that there is a problem with lifetime of mesh within meshfunction. It seems strange as mesh function constructors taking reference mesh are ignored in dolfin/swig/mesh/pre.i.

Comments (6)

  1. Juliane Braunsmann

    I'm not sure if commenting here is the correct place, but I seem to have found a related issue (2018.1):

    import fenics
    
    x_values_list = []
    for i in range(5):
        mesh = fenics.IntervalMesh(10, 0, 4)
        x_values = mesh.coordinates()
        print(x_values) #all good
        x_values_list.append(x_values)
    
    print(x_values_list) #prints rubbish
    
  2. Log in to comment