This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Mirror Mirror on the Wall - Who's the Weirdest SegFault of All?

+1 vote

I'm getting a segmentation fault and I can't figure out why. Here is a very minimal example.

this is the kernel cpp file. Call it tmp.cpp:

#include <boost/math/special_functions/bessel.hpp>
using boost::math::cyl_bessel_k;

namespace dolfin {

  class Xpr : public Expression
  {
  public:
    Xpr() : Expression() { }

    void eval(Array<double>& values, const Array<double>& y) const
    {
      values[0] = cyl_bessel_k( 0.5, 0.0002 );
    }
  };
}

and here is a python file to create it:

from dolfin import *

# This is to check the values i'm using are OK
from scipy import special as sp
print sp.kv( 0.5, 0.0002 )

# The FunctionSpace seems to be irrelevant
V = FunctionSpace(  UnitIntervalMesh( 22 ), "CG", 1 )

# If I comment this line out I get a warning message from PETsC! -------------
fund = Function( V )

# Read code from file.
c_file = open( "tmp.cpp" , 'r' )  

# We can compile the expression without a problem
xp = Expression( c_file.read() )

print "all good up to this point"
xp( 0.0 )

What's even weirder is that if I comment the line in python marked by -------, then PETSC
catches the segmentation fault (it says it is "signal 11") and kills the MPI processes itself!!!

Any clarifications would be most helpful.

asked Apr 14, 2016 by Yair Daon FEniCS User (1,350 points)
edited Apr 14, 2016 by Yair Daon

Hi, what fenics version are you using?

Works fine for me both with the stable version and the latest development version of FEniCS.

1.6.0 - checked from command line and from within python.

...