exasmr / openmc

OpenMC Monte Carlo Code
https://docs.openmc.org
MIT License
15 stars 9 forks source link

extend materials segfaults #32

Open gridley opened 1 year ago

gridley commented 1 year ago

https://github.com/exasmr/openmc/blob/3e13d39edd1897877ad54a7ccc97d14c9d53fe29/src/material.cpp#L1506

You can see that this segfaults pretty straightforwardly. It mallocs n materials, but we actually need materials_size + n.

If we let this sit for a bit, I have an implementation coming that fixes this and uses std::realloc for potential efficiency improvement. It also makes a few of the commonly used classes trivially copyable. Currently resolving a few other problems.

Lesson learned: in any future GPU-portable implementation, we must avoid managing memory by hand at all costs since it is so error prone.