Open lkeegan opened 2 years ago
ERROR in newformat: failed creating the format
ERROR in ConfigureCommand: cannot read BndValProblem specification
ERROR in CreateMultiGrid: format not found
ERROR in new: could not create multigrid
[E][ dunesim.cpp: 227] DuneSim :: GridError [createGrid:/tmp/setup-dune/dune-grid/dune/grid/uggrid/uggridfactory.cc:458]: Calling UG::2d::ConfigureCommand failed!
[E][ dunesim.cpp: 227] DuneSim :: GridError [createGrid:/tmp/setup-dune/dune-grid/dune/grid/uggrid/uggridfactory.cc:476]: UGGrid<2>::makeNewMultigrid failed!
ERROR in CreateMultiGrid: BVP not found
ERROR in new: could not create multigrid
Can reproduce in a single thread with:
auto m{getExampleModel(Mod::ABtoC)};
std::vector<std::string> comps{"comp"};
std::unique_ptr<simulate::DuneSim> s;
s = std::make_unique<simulate::DuneSim>(m, comps);
s = std::make_unique<simulate::DuneSim>(m, comps);
// this line segfaults:
s = std::make_unique<simulate::DuneSim>(m, comps);
Trace:
==990160==The signal is caused by a READ memory access.
#0 0x559dce0b11d0 in UG::D2::BNDS_Dispose(UG::HEAP*, void**) std_domain.cc
#1 0x559dce09a6d8 in UG::D2::DisposeElement(UG::D2::grid*, UG::D2::element*, int) ugm.cc
#2 0x559dce09cf58 in UG::D2::DisposeGrid(UG::D2::grid*) ugm.cc
#3 0x559dce09bd5c in UG::D2::DisposeMultiGrid(UG::D2::multigrid*) ugm.cc
#4 0x559dce0addb8 in UG::D2::NewCommand(int, char**, std::shared_ptr<PPIF::PPIFContext>) commands.cc
#5 0x559dce025ba3 in Dune::GridFactory<Dune::UGGrid<2>>::createGrid() uggridfactory.cc
#6 0x559dcc77a0bb in std::pair<std::vector<unsigned long, std::allocator<unsigned long>>, std::unique_ptr<Dune::UGGrid<2>, std::default_delete<Dune::UGGrid<2>>>> sme::simulate::detail::makeHostGrid<Dune::UGGrid<2>>(sme::mesh::Mesh const&) /home/liam/SSC/spatial-model-editor/core/simulate/src/dunegrid.hpp:88:32
#7 0x559dcc775afe in auto sme::simulate::makeDuneGrid<Dune::UGGrid<2>, Dune::mdgrid::DynamicSubDomainCountTraits<2, 1ul, Dune::mdgrid::AllCodims>>(sme::mesh::Mesh const&) /home/liam/SSC/spatial-model-editor/core/simulate/src/dunegrid.hpp:126:34
#8 0x559dcdf08287 in sme::simulate::DuneImpl::DuneImpl(sme::simulate::DuneConverter const&) /home/liam/SSC/spatial-model-editor/core/simulate/src/dunesim_impl.cpp:25:30
I am actually not sure if its possible to have different instances of UGGrid at the same time. What I know is that one grid can be traversed with multiple threads. In fact, next release of dune-copasi will be multi-threaded on the assembly part.
Describe the bug
With nthreads > 1, the first simulation on each thread works ok, but the second one crashes. nthreads=1 works.
Looks like a recurrence of a previous issue:
std::unique_ptr<DuneSim> sim
objectsim = std::make_unique<DuneSim>()
The problem seemed to be that the new dune sim would make use of some objects from the old dune sim (grid?) which were then de-allocated in the first dune sim destructor.
This was fixed by always first resetting the simulator
unique_ptr
before creating a new dun sim, i.e.However this doesn't work if we have multiple threads with DuneSim objects.
Example stack trace
To Reproduce Start optimization with dune and threads > 1