NVIDIA / NVIDIA/cccl

Device-scope segmented reduce temp storage allocation issue

Open
#894 0 comments 0 reactions 0 assignees View on GitHub
cub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

Device-scope segmented reduce contains the following short-circuit:

```cpp
if (num_segments <= 0)
{
return cudaSuccess;
}
```

which happens before `temp_storage_bytes` is initialized. The issue might take place:

```cpp
size_t temp_storage_bytes; // <- uninitialized
cub::DeviceSegmentedReduce::Reduce(nullptr, temp_storage_bytes);
thrust::device_vector temp_storage(temp_storage_bytes); // <- allocate random amount of memory

```

We guarantee to overwrite `temp_storage_bytes` in the docs. Therefore, we should fix this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.