Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for de/allocations pointing to null #257

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

vlkale
Copy link
Contributor

@vlkale vlkale commented Jun 6, 2024

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.

kp_space_time_stack.cpp: do null pointer check of ptr at the beginning of alloc and dealloc functions
@vlkale vlkale added the bug label Jun 6, 2024
@masterleinad
Copy link
Contributor

You need to run clang-format.

@vlkale
Copy link
Contributor Author

vlkale commented Jun 6, 2024

You need to run clang-format.

Thanks! Done.

Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me.

@crtrott crtrott merged commit 3cee564 into kokkos:develop Jun 10, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LAMMPS develop triggers assertion when kokkosp_allocate_data called with nullptr and size 0
3 participants