openmc
openmc copied to clipboard
OpenMP thread aborting can cause segfault?
A user recently reported that they were seeing a segfault. After following up, it was determined that they have some geometry errors and particles are being lost. As best as I can tell, the sequence of events that leads to a segfault is:
- Particles are being lost as they are transported
- The lost particle limit is hit on one OpenMP thread, which proceeds to call
fatal_error
, which callsstd::exit
- The call to
std::exit
starts tearing down memory - Meanwhile, other OpenMP threads are still trying to execute and eventually hit some piece of memory that no longer exists, causing a segfault
Running the same problem with a single thread does not result in a segfault. This would indicate we need a better way to tear down the program when an OpenMP thread reaches a fatal error.