|
Material* tmp = static_cast<Material*>(malloc(n * sizeof(Material))); |
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.
openmc/src/material.cpp
Line 1506 in 3e13d39
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.