[dune-fem] Segmentation fault when creating a new space for several times

Agnese, Marco m.agnese13 at imperial.ac.uk
Thu Jun 18 14:09:26 CEST 2015


Hi everybody,
I found a bug which I don't understand. I have created this simple test to trigger it (the grid is dune/fem/space/test/3dgrid.dgf):

#include <config.h>
#include <iostream>
#include <memory>

#include <dune/fem/space/discontinuousgalerkin.hh>
#include <dune/fem/space/lagrange.hh>
#include <dune/fem/space/combinedspace.hh>
#include <dune/fem/gridpart/leafgridpart.hh>

int main(int argc,char** argv)
{
  // init mpi
  Dune::Fem::MPIManager::initialize(argc,argv);
  try
  {
    // create grid
    typedef Dune::GridSelector::GridType GridType;
    typedef Dune::Fem::LeafGridPart<GridType> GridPartType;
    Dune::GridPtr<GridType> grid("3dgrid.dgf");

    // define spaces
    typedef Dune::Fem::FunctionSpace<double,double,GridType::dimensionworld,GridType::dimensionworld> FuncSpace1;
    typedef Dune::Fem::FunctionSpace<double,double,GridType::dimensionworld,1> FuncSpace2;
    typedef Dune::Fem::LagrangeDiscreteFunctionSpace<FuncSpace1,GridPartType,2> DiscreteFunctionSpaceType1;
    typedef Dune::Fem::LagrangeDiscontinuousGalerkinSpace<FuncSpace2,GridPartType,0> DiscreteFunctionSpaceType2;
    typedef Dune::Fem::TupleDiscreteFunctionSpace<DiscreteFunctionSpaceType1,DiscreteFunctionSpaceType2> DiscreteFunctionSpaceType;

    // create function space n times
    const int n(10);
    std::unique_ptr<GridPartType> gridPart;
    std::unique_ptr<DiscreteFunctionSpaceType> space;
    for(int i=0;i!=n;++i)
    {
      std::cout<<"iteration : "<<i<<std::endl;
      gridPart=std::unique_ptr<GridPartType>(new GridPartType(*grid));
      space=std::unique_ptr<DiscreteFunctionSpaceType>(new DiscreteFunctionSpaceType(*gridPart));
    }

    return 0;
  }
  catch(const Dune::Exception& exception)
  {
    std::cerr<<exception<<std::endl;
    return 1;
  }
}

The output is

iteration : 0
iteration : 1
iteration : 2
terminate called after throwing an instance of 'Dune::InvalidStateException'
[macomp000:06078] *** Process received signal ***
[macomp000:06078] Signal: Aborted (6)
[macomp000:06078] Signal code:  (-6)
[macomp000:06078] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340)[0x7fdcb6e00340]
[macomp000:06078] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x39)[0x7fdcb39d4bb9]
[macomp000:06078] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x148)[0x7fdcb39d7fc8]
[macomp000:06078] [ 3] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x155)[0x7fdcb72846b5]
[macomp000:06078] [ 4] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x5e836)[0x7fdcb7282836]
[macomp000:06078] [ 5] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x5d8f9)[0x7fdcb72818f9]
[macomp000:06078] [ 6] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(__gxx_personality_v0+0x52a)[0x7fdcb72824aa]
[macomp000:06078] [ 7] /lib/x86_64-linux-gnu/libgcc_s.so.1(+0xfff3)[0x7fdcb701dff3]
[macomp000:06078] [ 8] /lib/x86_64-linux-gnu/libgcc_s.so.1(_Unwind_Resume+0x57)[0x7fdcb701e517]
[macomp000:06078] [ 9] ./combinedspacetest[0x41d464]
[macomp000:06078] [10] ./combinedspacetest[0x43fb19]
[macomp000:06078] [11] ./combinedspacetest[0x408dfc]
[macomp000:06078] [12] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fdcb39bfec5]
[macomp000:06078] [13] ./combinedspacetest[0x409e3c]
[macomp000:06078] *** End of error message ***
Aborted (core dumped)

So it works for 2 iterations and then fails. What is the issue?

Thank you very much,
Cheers,
Marco.



More information about the dune-fem mailing list