Check for de/allocations pointing to null #257
Merged
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.
Fix #256.
To address this problem showing up in LAMMPS, the allocate and deallocate functions of the Kokkos Tool library space time stack (which record and maintain in a C++ set the memory allocations in a Kokkos application) need to have a check for the case of two allocations being null. The comparison operator (<) cannot distinguish two elements in the set that are both null.
We need to have null pointer check of the parameter
ptr
, at the beginning of allocate and deallocate function. If the ptr variable null, then the function should simply return.Within this null pointer check in space-time-stack allocation and deallocate functions, we should also discern whether the size of the ptr for allocation or deallocation is greater than 0 while the ptr is null. For that reason, we put in an assert just before returning.