DirichletBC::is_compatible and BoundaryCondition::check_arguments not working
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
DOLFIN |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Dear Dolfin devs,
I get a segfault when running a dolfin script. The segfault is not permanent, indicating an invalid memory access that might sometimes be valid by chance. (Somehow the memory patterns must have changed between dolfin 1.0 and 1.1 since I cannot remember getting any segfaults with dolfin 1.0, but I believe the underlying problem may affect both branches of dolfin).
This is obtained running dolfin from trunk (built with dorsal) on MacOS X 10.6.8 (64 bits).
When the segfault appears, the stack trace consistently shows :
Thread 0 Crashed: Dispatch queue: com.apple.
0 libdolfin.1.1.dylib 0x0000000103752d6e dolfin:
1 libdolfin.1.1.dylib 0x00000001037533c3 dolfin:
2 libdolfin.1.1.dylib 0x0000000103753748 dolfin:
3 _fem.so 0x0000000110c944c1 _wrap_Dirichlet
4 _fem.so 0x0000000110cc86ff _wrap_Dirichlet
5 org.python.python 0x00000001000c1f99 PyEval_EvalFrameEx + 25849
I run my full script under Valgrind and found a single "invalid write" problem in DirichletBC.apply. I managed to get the following minimal script to reproduce this 'invalid write' (note that this script does not produce a segfault, probably because h is not used after the BC has been applied) :
import sys
from dolfin import *
mesh = RectangleMesh (0, 0, 1., 1., 16, 16)
V = VectorFunctionS
Q = FunctionSpace(mesh, "CG", 1)
W = V * Q
u = Function(W) # with this line commented, the invalid write is still here, but the pattern is slightly different
g = Function(V)
bc = DirichletBC(
h = Function(V)
print "Bug is here !"
sys.stderr.
bc.apply(
sys.stderr.
I run the above script using valgrind to track the memory problem (valgrind --trace-
1
==32808== Invalid write of size 8
==32808== at 0x10615EDFF: VecSetValues_
==32808== by 0x10618178B: VecSetValues(
==32808== by 0x1046D7A70: dolfin:
==32808== by 0x116402C0E: _wrap_Dirichlet
...
==32808== Address 0x100d37a60 is not stack'd, malloc'd or (recently) free'd
2
So, the problem is when applying a boundary condition defined on a subspace of a mixed space (W.sub(0) in the example) on a function defined on the original subspace (V in the example). If the boundary condition is defined on V directly, there is no issue.
Thank you in advance for your help.
Best regards,
Timothée Lecomte
P.S. : Additionaly, I sometimes get an additional 'invalid read' for the same script, but I believe that this one may be fixed when the first one will be fixed :
==15643== Invalid read of size 8
==15643== at 0x1046E1B50: boost::
==15643== by 0x1046E0F60: dolfin:
==15643== by 0x104733118: dolfin:
==15643== by 0x104733EEF: std::_Rb_
==15643== by 0x104732FEB: dolfin:
==15643== by 0x10472CA11: dolfin:
...
==15643== Address 0xc01bb8289521fbf4 is not stack'd, malloc'd or (recently) free'd
You've answered by yourself - you can't apply DirichletBC(V1, ....) on Function(V2). Spaces involved must be same.
The bug is that: :is_compatible( GenericFunction & v) const on::check_ arguments( GenericMatrix* A, GenericVector* b,
const GenericVector* x) const
-bool DirichletBC:
doesn't work at the moment,
-void BoundaryConditi
doesn't work for subspaces at the moment,
so no check for compatibility is performed.
Jan