-
Notifications
You must be signed in to change notification settings - Fork 915
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
Fix memcheck error in ReplaceTest.NormalizeNansAndZerosMutable gtest #17610
Merged
rapids-bot
merged 2 commits into
rapidsai:branch-25.02
from
davidwendt:memcheck-norm-nans-test
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would not mind this option, but nothing wrong with current code either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidwendt this is what I was getting at above. My interpretation of
was that this change would somehow break things because the
mutable_column_view
would be a temporary and that was not permissible here. Perhaps I was misunderstanding though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is exactly what happens. The temporary created here
causes the compiler to call the
column_view const&
API instead of themutable_column_view&
API.The current code insures the appropriate API is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original change made here: #17436 was an attempt correct the API call by creating a
mutable_column_view
variable but inadvertently created the view to a destroyed temp column.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does that happen? I wouldn't have expected that overload to ever be selected in this way unless the overload for the same type was actually impossible to call, but
input->mutable_view()
returns a (non-const)mutable_column_view
that should be totally fine for this function signature.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I'm guessing because it is a temporary and passing a non-const temporary usually makes no sense since any modifications to the object that occur inside the function are just thrown away. I suppose the compiler is trying hard to help here by finding a better API candidate to call.
I feel like this https://godbolt.org/z/hW7cnKPxW illustrates that as well.
Perhaps we should not have an implicit operator conversion from
mutable_column_view
tocolumn_view
I would not expect that to be a common thing and making it explicit not be a big deal in our code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I put together a slightly modified version of your example that helped me. I found your example a bit different since there is no overload of the function that actually accepts an instance of
hello
itself. I would have thought that would always be preferred. Your explanation of why it wouldn't be makes sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the changes in #17436, we were passing a
mutable_column_view
rvalue tocudf::normalize_nans_and_zeros
. Since we cannot bind a rvalue to a non-const lvalue reference, thecudf::normalize_nans_and_zeros(mutable_column_view &)
overload could not be called, and the compiler instead converted themutable_column_view
tocolumn_view
so that the overload (cudf::normalize_nans_and_zeros(column_view const &)
) with the const reference parameter could be invoked.However, while trying to create a
mutable_column_view
lvalue, I accidentally created the view to a rvalue which does not make sense. Thank you for the fix, @davidwendt!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that this was a rule, thanks for stating it out explicitly. I guess the compiler prevents this since there's no sensible reason to allow this and it protects against user error modifying a parameter in a way that would have no effect.