Fix issue with Cell::get_contained_cells() utility function #2873
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue in the
Cell::find_parent_cells
andCell::Cell::get_contained_cells
utility functions. As it is now, the functions I think are only working when distrib materials are used. However, if used on regular cells, then there is an error mode that pops up. In particular, they pop up in theParentCellStack::compute_instance(int32_t distribcell_index)
function, which looks like:As the inputted
distribcell_index
will be-1
when inputted for non-distribcell cell, this will lead to reading at the-1
index of theoffset_
array, leading to undefined behavior.I'm not sure how helpful it would be to develop a standalone regression test for this issue, as it deals with undefined memory access so may not expose the issue. I can confirm though that on a feature branch I'm working on for random ray the fix works (as the new feature calls the
Cell::Cell::get_contained_cells
function and only works correctly when the fix is in place). Let me know though @pshriwise if you'd like to see a test go in for this and I can cook one up.Checklist