AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
549 stars 351 forks source link

Segfault when refluxing with fine layer that covers entire domain #1843

Open darylbond opened 3 years ago

darylbond commented 3 years ago

I am running into a segfault when my domain is completely covered by the fine grid.

The sequence of events is as follows:

  1. Generate an empty m_cfpatch in YAFluxRegister due to the complete coverage of the domain with the fine grid
  2. Call Reflux which calls ParallelCopy on m_crse_data and m_cfpatch
  3. Calls ParallelCopy_nowait, which exits at line 276 because we have an empty FabArray, thus it does not load the a pointer into pc_src
  4. Fail in ParallelCopy_finish when we try to call size() on pc_src as it is still null

I have attached my backtrace as well:

1  std::__shared_ptr<amrex::BARef, (__gnu_cxx::_Lock_policy)2>::get                             shared_ptr_base.h        1310 0x414fce 
2  std::__shared_ptr_access<amrex::BARef, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get     shared_ptr_base.h        1021 0x416ae4 
3  std::__shared_ptr_access<amrex::BARef, (__gnu_cxx::_Lock_policy)2, false, false>::operator-> shared_ptr_base.h        1015 0x414fbc 
4  amrex::BoxArray::size                                                                        AMReX_BoxArray.H         581  0x443484 
5  amrex::FabArrayBase::size                                                                    AMReX_FabArrayBase.H     101  0x4d0e0a 
6  amrex::FabArray<amrex::FArrayBox>::ParallelCopy_finish                                       AMReX_FabArrayCommI.H    474  0x7af263 
7  amrex::FabArray<amrex::FArrayBox>::ParallelCopy                                              AMReX_FabArrayCommI.H    259  0x7abbdf 
8  amrex::FabArray<amrex::FArrayBox>::ParallelCopy                                              AMReX_FabArray.H         554  0x7e0403 
9  amrex::FabArray<amrex::FArrayBox>::ParallelCopy                                              AMReX_FabArray.H         471  0x7db687 
10 amrex::EBFluxRegister::Reflux                                                                AMReX_EBFluxRegister.cpp 251  0xd4016a 
11 MFP::post_timestep                                                                           MFP.cpp                  309  0x4336b4 
12 amrex::Amr::timeStep                                                                         AMReX_Amr.cpp            2043 0x9ed356 
13 amrex::Amr::coarseTimeStep                                                                   AMReX_Amr.cpp            2094 0x9ed920 
14 main                                                                                         main.cpp                 162  0x411b6b 
darylbond commented 3 years ago

@kngott I think you may want to take a look at this

kngott commented 3 years ago

Thank you for the concise description of the problem! It was extremely helpful.

We just pushed a new pull request to development that should fix the problem. Please pull development, try it out, and let us know: https://github.com/AMReX-Codes/amrex/pull/1845

darylbond commented 3 years ago

@kngott that seems to have fixed it. Thanks for the quick response!