Skip to content

Commit

Permalink
Fix memcheck error in ReplaceTest.NormalizeNansAndZerosMutable gtest (#…
Browse files Browse the repository at this point in the history
…17610)

Fixes memcheck error found in nightly build checks in the STREAM_REPLACE_TEST's `ReplaceTest.NormalizeNansAndZerosMutable` gtest. The mutable-view passed to the `cudf::normalize_nans_and_zeros` API was pointing to invalidated data.

The following line created the invalid view
```
cudf::mutable_column_view mutable_view = cudf::column(input, cudf::test::get_default_stream());
```
The temporary `cudf::column` is destroyed once the `mutable_view` is created so this view would now point to a freed column. The view must be created from a non-temporary column and also must be non-temporary itself so that it is not implicitly converted to a `column_view`.

Error introduced by #17436

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Vukasin Milovanovic (https://github.com/vuule)

URL: #17610
  • Loading branch information
davidwendt authored Dec 17, 2024
1 parent 24aacb2 commit 267c7f2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cpp/tests/streams/replace_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ TEST_F(ReplaceTest, NormalizeNansAndZeros)

TEST_F(ReplaceTest, NormalizeNansAndZerosMutable)
{
auto nan = std::numeric_limits<double>::quiet_NaN();
auto input_column = cudf::test::make_type_param_vector<double>({-0.0, 0.0, -nan, nan, nan});
cudf::test::fixed_width_column_wrapper<double> input(input_column.begin(), input_column.end());
cudf::mutable_column_view mutable_view = cudf::column(input, cudf::test::get_default_stream());
cudf::normalize_nans_and_zeros(mutable_view, cudf::test::get_default_stream());
auto nan = std::numeric_limits<double>::quiet_NaN();
auto data = cudf::test::make_type_param_vector<double>({-0.0, 0.0, -nan, nan, nan});
auto input = cudf::test::fixed_width_column_wrapper<double>(data.begin(), data.end()).release();
auto view = input->mutable_view();
cudf::normalize_nans_and_zeros(view, cudf::test::get_default_stream());
}

0 comments on commit 267c7f2

Please sign in to comment.