Random behavior when getting coordinates of a UnitSquareMesh's BoundaryMesh

Issue #1024 resolved
Karl Erik created an issue

The call BoundaryMesh(mesh, "exterior").coordinates() seems to randomly behave differently from first calling BoundaryMesh(mesh, "exterior") and then using its .coordinates() method. The attached script prints 0 when they return the same, and running it 10 times yielded non-zero output 7 times.

Bug reproduced for me in a fairly recent stable docker image, and some informal testing suggests it's present in 2018.1, but not in 2017.2, although I did not test rigorously enough to be sure.

EDIT: Prepended 3 lines to the script to rule out garbage collection.

Comments (5)

  1. Lawrence Mitchell

    A stab in the dark, the refcounting is somehow broken, such that coordinates() does not return something that references the boundary mesh. So when you call BoundaryMesh(...).coordinates(), the boundary mesh is collected, and then the coordinates array holds nonsense.

  2. Karl Erik reporter

    I don't think that's the cause because prepending import gc; gc.disable() to the script does not seem to fix it. I don't know enough about Python internals to say whether there are other things which could go wrong, though.

  3. Log in to comment